diff --git a/src/diagnostics.ts b/src/diagnostics.ts index efcd94f48d..1905a5e36a 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -427,17 +427,18 @@ export function traceMixed( } channel.end.publish(context); - channel.asyncStart.publish(context); return result.then( (value) => { context.result = value; + channel.asyncStart.publish(context); channel.asyncEnd.publish(context); return value; }, (err: unknown) => { context.error = err; channel.error.publish(context); + channel.asyncStart.publish(context); channel.asyncEnd.publish(context); throw err; }, diff --git a/src/execution/__tests__/diagnostics-execute-test.ts b/src/execution/__tests__/diagnostics-execute-test.ts index afaa3fb728..9c0cf4f4cf 100644 --- a/src/execution/__tests__/diagnostics-execute-test.ts +++ b/src/execution/__tests__/diagnostics-execute-test.ts @@ -121,6 +121,7 @@ describe('execute diagnostics channel', () => { rawVariableValues: undefined, operationName: undefined, operationType: OperationTypeNode.QUERY, + result, }, }, { @@ -201,17 +202,18 @@ describe('execute diagnostics channel', () => { }, }, { - channel: 'asyncStart', + channel: 'error', context: { schema: asyncDeferSchema, document, rawVariableValues: undefined, operationName: 'Deferred', operationType: OperationTypeNode.QUERY, + error, }, }, { - channel: 'error', + channel: 'asyncStart', context: { schema: asyncDeferSchema, document, @@ -456,6 +458,7 @@ describe('execute root selection set diagnostics channel', () => { rawVariableValues: undefined, operationName: undefined, operationType: OperationTypeNode.QUERY, + result, }, }, { diff --git a/src/execution/__tests__/diagnostics-resolve-test.ts b/src/execution/__tests__/diagnostics-resolve-test.ts index 5b21232251..640c75b68f 100644 --- a/src/execution/__tests__/diagnostics-resolve-test.ts +++ b/src/execution/__tests__/diagnostics-resolve-test.ts @@ -130,6 +130,7 @@ describe('resolve diagnostics channel', () => { args: {}, isDefaultResolver: true, fieldPath: 'async', + result: 'hello-async', }, }, { @@ -207,6 +208,7 @@ describe('resolve diagnostics channel', () => { args: {}, isDefaultResolver: true, fieldPath: 'async', + result: 'hello-thenable', }, }, { @@ -325,7 +327,7 @@ describe('resolve diagnostics channel', () => { }, }, { - channel: 'asyncStart', + channel: 'error', context: { fieldName: 'asyncFail', alias: 'asyncFail', @@ -334,10 +336,11 @@ describe('resolve diagnostics channel', () => { args: {}, isDefaultResolver: true, fieldPath: 'asyncFail', + error, }, }, { - channel: 'error', + channel: 'asyncStart', context: { fieldName: 'asyncFail', alias: 'asyncFail', diff --git a/src/execution/__tests__/diagnostics-subscribe-test.ts b/src/execution/__tests__/diagnostics-subscribe-test.ts index 018da50bf5..48b7cdbd0d 100644 --- a/src/execution/__tests__/diagnostics-subscribe-test.ts +++ b/src/execution/__tests__/diagnostics-subscribe-test.ts @@ -145,6 +145,7 @@ describe('subscribe diagnostics channel', () => { rawVariableValues: undefined, operationName: undefined, operationType: OperationTypeNode.SUBSCRIPTION, + result, }, }, { @@ -474,6 +475,7 @@ describe('subscribe diagnostics channel', () => { rawVariableValues: undefined, operationName: 'S', operationType: OperationTypeNode.SUBSCRIPTION, + result, }, }, {