Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Jul 25, 2024
1 parent baaf870 commit e6b2a18
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-bees-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-mesh/serve-runtime': patch
---

Fix the issue when you go to landing page then GraphiQL, queries are not executed
6 changes: 1 addition & 5 deletions packages/fusion/runtime/src/unifiedGraphManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class UnifiedGraphManager<TContext> {
private inContextSDK;
private initialUnifiedGraph$: MaybePromise<true>;
private disposableStack = new AsyncDisposableStack();
private _transportEntryMap: Record<string, TransportEntry>;
_transportEntryMap: Record<string, TransportEntry>;
private _transportExecutorStack: AsyncDisposableStack;
constructor(private opts: UnifiedGraphManagerOptions<TContext>) {
this.handleUnifiedGraph = opts.handleUnifiedGraph || handleFederationSupergraph;
Expand Down Expand Up @@ -185,10 +185,6 @@ export class UnifiedGraphManager<TContext> {
);
}

public getTransportEntryMap() {
return mapMaybePromise(this.ensureUnifiedGraph(), () => this._transportEntryMap);
}

public getUnifiedGraph() {
return mapMaybePromise(this.ensureUnifiedGraph(), () => this.unifiedGraph);
}
Expand Down
14 changes: 9 additions & 5 deletions packages/serve-runtime/src/createServeRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,24 @@ export function createServeRuntime<TContext extends Record<string, any> = Record
disposableStack.use(unifiedGraphManager);
subgraphInformationHTMLRenderer = async () => {
const htmlParts: string[] = [];
let supergraphLoadedPlace: string;
let supergraphLoadedPlace = './supergraph.graphql';
if ('hive' in config && config.hive.endpoint) {
supergraphLoadedPlace = 'Hive CDN <br>' + config.hive.endpoint;
} else if ('supergraph' in config) {
if (typeof config.supergraph === 'function') {
const fnName = config.supergraph.name || '';
supergraphLoadedPlace = `a custom loader ${fnName}`;
} else if (typeof config.supergraph === 'string') {
supergraphLoadedPlace = config.supergraph;
}
}
let loaded = false;
let loadError: Error;
let transportEntryMap: Record<string, TransportEntry>;
try {
transportEntryMap = await unifiedGraphManager.getTransportEntryMap();
// TODO: Workaround for the issue
// When you go to landing page, then GraphiQL, GW stops working
const schema = await getSchema();
schemaChanged(schema);
loaded = true;
} catch (e) {
loaded = false;
Expand All @@ -233,8 +237,8 @@ export function createServeRuntime<TContext extends Record<string, any> = Record
htmlParts.push(`<p><strong>Source: </strong> <i>${supergraphLoadedPlace}</i></p>`);
htmlParts.push(`<table>`);
htmlParts.push(`<tr><th>Subgraph</th><th>Transport</th><th>Location</th></tr>`);
for (const subgraphName in transportEntryMap) {
const transportEntry = transportEntryMap[subgraphName];
for (const subgraphName in unifiedGraphManager._transportEntryMap) {
const transportEntry = unifiedGraphManager._transportEntryMap[subgraphName];
htmlParts.push(`<tr>`);
htmlParts.push(`<td>${subgraphName}</td>`);
htmlParts.push(`<td>${transportEntry.kind}</td>`);
Expand Down
2 changes: 1 addition & 1 deletion packages/serve-runtime/src/useFetchDebug.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loggerForExecutionRequest } from '@graphql-mesh/fusion-runtime';
import type { Logger } from '@graphql-mesh/types';
import type { MeshServePlugin } from './types';
import { requestIdMap } from './useRequestId';
import { requestIdMap } from './useRequestId.js';

export function useFetchDebug<TContext>({ logger }: { logger: Logger }): MeshServePlugin<TContext> {
return {
Expand Down

0 comments on commit e6b2a18

Please sign in to comment.