Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .changeset/@graphql-hive_gateway-664-dependencies.md

This file was deleted.

8 changes: 8 additions & 0 deletions packages/gateway/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @graphql-hive/gateway

## 1.10.3

### Patch Changes

- [#664](https://github.com/graphql-hive/gateway/pull/664) [`b4d4760`](https://github.com/graphql-hive/gateway/commit/b4d4760861f360bed0e1566a50833164678fe3d5) Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:

- Updated dependency [`@graphql-mesh/cache-upstash-redis@^0.0.4` ↗︎](https://www.npmjs.com/package/@graphql-mesh/cache-upstash-redis/v/0.0.4) (from `^0.0.3`, in `dependencies`)

## 1.10.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/gateway/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-hive/gateway",
"version": "1.10.2",
"version": "1.10.3",
"type": "module",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-hive/gateway-runtime",
"version": "1.4.15",
"version": "1.4.16",
"type": "module",
"repository": {
"type": "git",
Expand Down
50 changes: 18 additions & 32 deletions packages/runtime/src/plugins/useDelegationPlanDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function useDelegationPlanDebug<
fetchAPI = yoga.fetchAPI;
},
onDelegationPlan({
subgraph,
typeName,
variables,
fragments,
Expand All @@ -23,13 +22,10 @@ export function useDelegationPlanDebug<
logger = opts.logger,
}) {
const planId = fetchAPI.crypto.randomUUID();
const delegationPlanStartLogger = logger.child('delegation-plan-start');
const planLogger = logger.child({ planId, typeName });
const delegationPlanStartLogger = planLogger.child('delegation-plan-start');
delegationPlanStartLogger.debug(() => {
const logObj: Record<string, any> = {
planId,
subgraph,
typeName,
};
const logObj: Record<string, any> = {};
if (variables && Object.keys(variables).length) {
logObj['variables'] = variables;
}
Expand All @@ -51,21 +47,16 @@ export function useDelegationPlanDebug<
}
return logObj;
});
const start = performance.now();
return ({ delegationPlan }) => {
const delegationPlanDoneLogger = logger.child('delegation-plan-done');
delegationPlanDoneLogger.debug(() => ({
planId,
plan: delegationPlan.map((plan) => {
const planObj: Record<string, string> = {};
for (const [subschema, selectionSet] of plan) {
if (subschema.name) {
planObj[subschema.name] = print(selectionSet);
}
delegationPlanDoneLogger.debug(() => delegationPlan.map((plan) => {
const planObj: Record<string, string> = {};
for (const [subschema, selectionSet] of plan) {
if (subschema.name) {
planObj[subschema.name] = print(selectionSet);
}
return planObj;
}),
duration: performance.now() - start,
}
return planObj;
}));
};
},
Expand All @@ -79,16 +70,12 @@ export function useDelegationPlanDebug<
typeName,
logger = opts.logger,
}) {
let stageId: string;
let contextLog = stageExecuteLogById.get(context);
if (!contextLog) {
contextLog = new Set();
stageExecuteLogById.set(context, contextLog);
}
const delegationStageLogger = logger.child('delegation-stage-execute');
const log = {
subgraph,
typeName,
key: JSON.stringify(key),
object: JSON.stringify(object),
selectionSet: print(selectionSet),
Expand All @@ -98,24 +85,23 @@ export function useDelegationPlanDebug<
return;
}
contextLog.add(logStr);
stageId = fetchAPI.crypto.randomUUID();
delegationStageLogger.debug('start', () => {
const logMeta: Record<string, string> = {
stageId: fetchAPI.crypto.randomUUID(),
subgraph,
typeName,
};
const delegationStageLogger = logger.child(logMeta);
delegationStageLogger.debug('delegation-plan-start', () => {
return {
stageId,
...log,
path: pathToArray(info.path).join(' | '),
};
});
const start = performance.now();
return ({ result }) => {
const delegationStageExecuteDoneLogger = logger.child(
'delegation-stage-execute-done',
);
delegationStageExecuteDoneLogger.debug(() => ({
stageId,
result: JSON.stringify(result, null),
duration: performance.now() - start,
}));
delegationStageExecuteDoneLogger.debug(() => result);
};
},
};
Expand Down
47 changes: 22 additions & 25 deletions packages/runtime/src/plugins/useSubgraphExecuteDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ export function useSubgraphExecuteDebug<
onYogaInit({ yoga }) {
fetchAPI = yoga.fetchAPI;
},
onSubgraphExecute({ executionRequest, logger = opts.logger }) {
const subgraphExecuteId = fetchAPI.crypto.randomUUID();
onSubgraphExecute({
executionRequest,
logger = opts.logger,
}) {
const subgraphExecuteHookLogger = logger.child({
subgraphExecuteId,
subgraphExecuteId: fetchAPI.crypto.randomUUID(),
});
const subgraphExecuteStartLogger = subgraphExecuteHookLogger.child(
'subgraph-execute-start',
);
subgraphExecuteStartLogger.debug(() => {
const logData: Record<string, any> = {};
if (executionRequest.document) {
logData['query'] = defaultPrintFn(executionRequest.document);
}
if (
executionRequest.variables &&
Object.keys(executionRequest.variables).length
) {
logData['variables'] = executionRequest.variables;
}
return logData;
});
if (executionRequest) {
const subgraphExecuteStartLogger = subgraphExecuteHookLogger.child(
'subgraph-execute-start',
);
subgraphExecuteStartLogger.debug(() => {
const logData: Record<string, any> = {};
if (executionRequest.document) {
logData['query'] = defaultPrintFn(executionRequest.document);
}
if (
executionRequest.variables &&
Object.keys(executionRequest.variables).length
) {
logData['variables'] = executionRequest.variables;
}
return logData;
});
}
const start = performance.now();
return function onSubgraphExecuteDone({ result }) {
const subgraphExecuteEndLogger = subgraphExecuteHookLogger.child(
Expand All @@ -54,10 +54,7 @@ export function useSubgraphExecuteDebug<
},
};
}
subgraphExecuteEndLogger.debug(() => ({
result,
duration: performance.now() - start,
}));
subgraphExecuteEndLogger.debug(result);
return void 0;
};
},
Expand Down
Loading