diff --git a/index.js b/index.js index 2e547690..38b04608 100644 --- a/index.js +++ b/index.js @@ -566,13 +566,20 @@ const plugin = fp(async function (app, opts) { return maybeFormatErrors(execution, context) } + const abortController = new AbortController() + reply?.raw.on('close', () => { + console.log('aborted (log from Mercurius)') + abortController.abort('Connection closed.') + }) + const execution = await executeGraphql(opts.defer, { schema: modifiedSchema || fastifyGraphQl.schema, document: modifiedDocument || document, rootValue: root, contextValue: context, variableValues: variables, - operationName + operationName, + signal: abortController.signal }) /* istanbul ignore next */ diff --git a/package.json b/package.json index 73dcfb98..e50c1ab1 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "homepage": "https://mercurius.dev", "peerDependencies": { - "graphql": "^17.0.0-alpha.2" + "graphql": "canary-pr-3791" }, "devDependencies": { "@graphql-tools/merge": "^8.0.0",