{"_id":"@aldahick/apollo-fastify","_rev":"7-040344e0b569904f3acc477c33a39f25","name":"@aldahick/apollo-fastify","dist-tags":{"latest":"4.0.0"},"versions":{"2.1.1":{"name":"@aldahick/apollo-fastify","version":"2.1.1","author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"license":"MIT","_id":"@aldahick/apollo-fastify@2.1.1","maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"dist":{"shasum":"75e299c5b76080d3d38a1e089d555f3fc791f4d3","tarball":"https://registry.npmjs.org/@aldahick/apollo-fastify/-/apollo-fastify-2.1.1.tgz","fileCount":19,"integrity":"sha512-Z+hpvfxrGrHI/R5abY+kiRL64hLWmMORGaUT0RnFSOMGUeXMLFuAXfE4pIaYAYzySLutW5sToE1IUH+nYiNNRA==","signatures":[{"sig":"MEUCIAzbwvh5A9D9oKZiWmL3mLjwYEtOeybFHgw+vFMTNfKXAiEAjiyt0MvFgc52A7Zj0ukAI3lVcgVIyBQxMGndePYTCzQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17115},"type":"module","_from":"file:aldahick-apollo-fastify-2.1.1.tgz","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=16"},"scripts":{"lint":"biome check src","build":"tsc","lint:fix":"pnpm lint --write --unsafe"},"_npmUser":{"name":"aldahick","email":"alex@alexhicks.net"},"_resolved":"/tmp/9ffb714dbd493d6fa33084289429b9a4/aldahick-apollo-fastify-2.1.1.tgz","_integrity":"sha512-Z+hpvfxrGrHI/R5abY+kiRL64hLWmMORGaUT0RnFSOMGUeXMLFuAXfE4pIaYAYzySLutW5sToE1IUH+nYiNNRA==","repository":{"url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git","type":"git"},"_npmVersion":"10.9.0","description":"An Apollo Server integration for use with Fastify","directories":{},"_nodeVersion":"22.10.0","dependencies":{"fastify-plugin":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"fastify":"5.0.0","graphql":"16.9.0","typescript":"5.6.3","@types/node":"22.8.4","@apollo/server":"4.11.1","@biomejs/biome":"1.9.4","@vitest/coverage-v8":"2.1.4","@apollo/utils.withrequired":"3.0.0","@apollo/server-integration-testsuite":"4.11.1"},"peerDependencies":{"fastify":"^5.0.0","@apollo/server":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/apollo-fastify_2.1.1_1730240025849_0.7449854626675174","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"@aldahick/apollo-fastify","version":"3.0.0","author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"license":"MIT","_id":"@aldahick/apollo-fastify@3.0.0","maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"dist":{"shasum":"14e1078c3a863502e70502b82303f2d4ab131403","tarball":"https://registry.npmjs.org/@aldahick/apollo-fastify/-/apollo-fastify-3.0.0.tgz","fileCount":19,"integrity":"sha512-X8vgyegnp7mee1JDvdvsXG0G0cru+UegXvB0QWEYpxporx4ElkxLVMHWV7H0KJ1fgW2CEm+AhjTKmBe3EUzO4A==","signatures":[{"sig":"MEQCIAuImxQXa1lMOBLxISLrwUY6kKS/mGMYoE9eYLZjz16CAiAZ2bl7723rDvhSr/TcjTzW3eevuq3VD1Seo28FOlE/wg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17115},"type":"module","_from":"file:aldahick-apollo-fastify-3.0.0.tgz","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=16"},"scripts":{"lint":"biome check src","build":"tsc","lint:fix":"pnpm lint --write --unsafe"},"_npmUser":{"name":"aldahick","email":"alex@alexhicks.net"},"_resolved":"/tmp/507069adbb3df88cbccffc741577a985/aldahick-apollo-fastify-3.0.0.tgz","_integrity":"sha512-X8vgyegnp7mee1JDvdvsXG0G0cru+UegXvB0QWEYpxporx4ElkxLVMHWV7H0KJ1fgW2CEm+AhjTKmBe3EUzO4A==","repository":{"url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git","type":"git"},"_npmVersion":"10.9.0","description":"An Apollo Server integration for use with Fastify","directories":{},"_nodeVersion":"22.10.0","dependencies":{"fastify-plugin":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"fastify":"5.0.0","graphql":"16.9.0","typescript":"5.6.3","@types/node":"22.8.4","@apollo/server":"4.11.1","@biomejs/biome":"1.9.4","@vitest/coverage-v8":"2.1.4","@apollo/utils.withrequired":"3.0.0","@apollo/server-integration-testsuite":"4.11.1"},"peerDependencies":{"fastify":"^5.0.0","@apollo/server":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/apollo-fastify_3.0.0_1730240070466_0.6554252062102637","host":"s3://npm-registry-packages"}},"3.0.1":{"name":"@aldahick/apollo-fastify","version":"3.0.1","author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"license":"MIT","_id":"@aldahick/apollo-fastify@3.0.1","maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"dist":{"shasum":"298bd3c7d08872d26f5294dbcdd948c22a5964ad","tarball":"https://registry.npmjs.org/@aldahick/apollo-fastify/-/apollo-fastify-3.0.1.tgz","fileCount":19,"integrity":"sha512-nSMOgKQyAPshz92l8Eql13Y77IJ/9WuCOw1RS7wvwDbuZa8GCuf4VYy6JpHItGjH7pXmom4zGl9ErwLB//vdwA==","signatures":[{"sig":"MEUCIEMZ0jsERCyTLc4HHsgB6Squr+WEL4dsCA1JEH4mnJfrAiEA17dpSzWAhbfKvqPSDOt7g5FSnMBdV6t4RmyvqtWzwrE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17142},"main":"dist/index.js","type":"module","_from":"file:aldahick-apollo-fastify-3.0.1.tgz","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=16"},"scripts":{"lint":"biome check src","build":"tsc","lint:fix":"pnpm lint --write --unsafe"},"_npmUser":{"name":"aldahick","email":"alex@alexhicks.net"},"_resolved":"/tmp/2a470d71803c4fc4707fbbf666ead3a4/aldahick-apollo-fastify-3.0.1.tgz","_integrity":"sha512-nSMOgKQyAPshz92l8Eql13Y77IJ/9WuCOw1RS7wvwDbuZa8GCuf4VYy6JpHItGjH7pXmom4zGl9ErwLB//vdwA==","repository":{"url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git","type":"git"},"_npmVersion":"10.9.0","description":"An Apollo Server integration for use with Fastify","directories":{},"_nodeVersion":"22.10.0","dependencies":{"fastify-plugin":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"fastify":"5.0.0","graphql":"16.9.0","typescript":"5.6.3","@types/node":"22.8.4","@apollo/server":"4.11.1","@biomejs/biome":"1.9.4","@vitest/coverage-v8":"2.1.4","@apollo/utils.withrequired":"3.0.0","@apollo/server-integration-testsuite":"4.11.1"},"peerDependencies":{"fastify":"^5.0.0","@apollo/server":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/apollo-fastify_3.0.1_1730240296357_0.31047018009701155","host":"s3://npm-registry-packages"}},"2.2.0":{"name":"@aldahick/apollo-fastify","version":"2.2.0","author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"license":"MIT","_id":"@aldahick/apollo-fastify@2.2.0","maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"dist":{"shasum":"2203cd2d55b38fea128368688240803136262472","tarball":"https://registry.npmjs.org/@aldahick/apollo-fastify/-/apollo-fastify-2.2.0.tgz","fileCount":19,"integrity":"sha512-iyBC+isV3QQdvGooAe6mAYpCBlBGnPYyGwoNE3eFjbPohlf+PN59PPRp4ocq9Vejshc2y7sJ4euTI0VtlCeWjg==","signatures":[{"sig":"MEUCIFhx/QiUwue5qrqGRVS8CETDUkA0yueNDauJ56DyC1oKAiEAm+lSAcXaHixxotfQ2OIoK+vKuBMVmU50qDotvR6VYvM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17117},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=16"},"gitHead":"884d1b322ced56cb1d514196b9d193034b9049d9","scripts":{"lint":"biome check src","build":"tsc","lint:fix":"pnpm lint --write --unsafe","prepublishOnly":"rm -rf dist && pnpm build"},"_npmUser":{"name":"aldahick","email":"alex@alexhicks.net"},"repository":{"url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git","type":"git"},"_npmVersion":"10.9.0","description":"An Apollo Server integration for use with Fastify","directories":{},"_nodeVersion":"22.11.0","dependencies":{"fastify-plugin":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"fastify":"5.0.0","graphql":"16.9.0","typescript":"5.6.3","@types/node":"22.8.4","@apollo/server":"4.11.1","@biomejs/biome":"1.9.4","@vitest/coverage-v8":"2.1.4","@apollo/utils.withrequired":"3.0.0","@apollo/server-integration-testsuite":"4.11.1"},"peerDependencies":{"fastify":"^5.0.0","@apollo/server":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/apollo-fastify_2.2.0_1730490296514_0.1160162221251575","host":"s3://npm-registry-packages"}},"2.2.1":{"name":"@aldahick/apollo-fastify","version":"2.2.1","author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"license":"MIT","_id":"@aldahick/apollo-fastify@2.2.1","maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"dist":{"shasum":"7be7edf96ce2bce4f8e5d2b6029a0ef5e4e3bc92","tarball":"https://registry.npmjs.org/@aldahick/apollo-fastify/-/apollo-fastify-2.2.1.tgz","fileCount":19,"integrity":"sha512-UP7xvQJXpti5JdNByG2ukjs1XMOfxPPLX5PoqkLBrFqnXo768EUwyzEZmvVOPnJ+5ZDomH8PxqpWnd6HGdAl2g==","signatures":[{"sig":"MEQCIC1AiT+O55Yukc2Awo0LlZ1MaVUW/h75H0PHSyY4twL1AiBfrHvYxMqkOgX8NGTsusNzQ22PQqKOShwHpSyQ3XmEEQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18833},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"gitHead":"f7d65778c6a0950632c50e3fa18baa9f155f35eb","scripts":{"lint":"biome check src","build":"tsc","lint:fix":"pnpm lint --write --unsafe","prepublishOnly":"rm -rf dist && pnpm build"},"_npmUser":{"name":"aldahick","email":"alex@alexhicks.net"},"repository":{"url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git","type":"git"},"_npmVersion":"10.9.0","description":"An Apollo Server integration for use with Fastify","directories":{},"_nodeVersion":"22.11.0","dependencies":{"fastify-plugin":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"fastify":"5.0.0","graphql":"16.9.0","typescript":"5.6.3","@types/node":"22.8.4","@apollo/server":"4.11.1","@biomejs/biome":"1.9.4","@vitest/coverage-v8":"2.1.4","@apollo/utils.withrequired":"3.0.0","@apollo/server-integration-testsuite":"4.11.1"},"peerDependencies":{"fastify":"^5.0.0","@apollo/server":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/apollo-fastify_2.2.1_1730511411446_0.5511417992964518","host":"s3://npm-registry-packages"}},"2.2.2":{"name":"@aldahick/apollo-fastify","version":"2.2.2","author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"license":"MIT","_id":"@aldahick/apollo-fastify@2.2.2","maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"dist":{"shasum":"9dfccae6d428eb2ac1286e0f9a11d140c10a6694","tarball":"https://registry.npmjs.org/@aldahick/apollo-fastify/-/apollo-fastify-2.2.2.tgz","fileCount":19,"integrity":"sha512-HwPsp6L5SEHUM5Fh7F5A/+wnkLj+S1agNB4+ghsDw8GlCBarxy6MLcfspcuhVT4bjTVxq07SVV17ztxGotpaUw==","signatures":[{"sig":"MEUCIQClURT2pMrOqqlzVzfKVnVHE7y1bQrVJZYQtRUcJt3E9wIgFIGxOE03Ma4aNmE2OKPEaEKYfgl7poQCCflYL93HMQA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18833},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"gitHead":"7f10bd0c8c838f03479a7380165cbc85e0c5c0d4","scripts":{"lint":"biome check src","build":"tsc","lint:fix":"pnpm lint --write --unsafe","prepublishOnly":"rm -rf dist && pnpm build"},"_npmUser":{"name":"aldahick","email":"alex@alexhicks.net"},"repository":{"url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git","type":"git"},"_npmVersion":"10.9.0","description":"An Apollo Server integration for use with Fastify","directories":{},"_nodeVersion":"22.11.0","dependencies":{"fastify-plugin":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"fastify":"5.0.0","graphql":"16.9.0","typescript":"5.6.3","@types/node":"22.8.4","@apollo/server":"4.11.1","@biomejs/biome":"1.9.4","@vitest/coverage-v8":"2.1.4","@apollo/utils.withrequired":"3.0.0","@apollo/server-integration-testsuite":"4.11.1"},"peerDependencies":{"fastify":"^5.0.0","@apollo/server":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/apollo-fastify_2.2.2_1730511589670_0.06805790565166459","host":"s3://npm-registry-packages"}},"4.0.0":{"name":"@aldahick/apollo-fastify","version":"4.0.0","description":"An Apollo Server integration for use with Fastify","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"repository":{"type":"git","url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git"},"engines":{"node":">=22"},"dependencies":{"fastify-plugin":"^5.0.1"},"peerDependencies":{"@apollo/server":"^5.0.0","fastify":"^5.0.0"},"devDependencies":{"@apollo/server":"5.0.0","@apollo/server-integration-testsuite":"5.0.0","@apollo/utils.withrequired":"3.0.0","@biomejs/biome":"2.1.4","@types/node":"24.2.1","@vitest/coverage-v8":"3.2.4","fastify":"5.4.0","graphql":"16.11.0","typescript":"5.9.2"},"scripts":{"build":"tsc","lint":"biome check src","lint:fix":"pnpm lint --write --unsafe"},"_id":"@aldahick/apollo-fastify@4.0.0","_integrity":"sha512-90Vqh+RXWQZOJnqK0WRXb/gOnVJhc/clzGxfM5VmEc6w6YHbDZSjzoumW9W++rNrMEkCJkpAOB0qlSH75IzofA==","_resolved":"/tmp/050a1750f3bac3af4c4e70e101bf237d/aldahick-apollo-fastify-4.0.0.tgz","_from":"file:aldahick-apollo-fastify-4.0.0.tgz","_nodeVersion":"22.17.1","_npmVersion":"11.5.1","dist":{"integrity":"sha512-90Vqh+RXWQZOJnqK0WRXb/gOnVJhc/clzGxfM5VmEc6w6YHbDZSjzoumW9W++rNrMEkCJkpAOB0qlSH75IzofA==","shasum":"1bfc3adc4968562699edee563a9580e25060aa9e","tarball":"https://registry.npmjs.org/@aldahick/apollo-fastify/-/apollo-fastify-4.0.0.tgz","fileCount":19,"unpackedSize":18058,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFqO8HdaCHlGUJX0DETLTP8B00V03UJz7ofqh7DSs8b4AiEAj6Gm/7m2fiDjPSkthbTj56FB8eGzkkBb3p366ZI0ytM="}]},"_npmUser":{"name":"aldahick","email":"alex@alexhicks.net"},"directories":{},"maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/apollo-fastify_4.0.0_1754769180396_0.03310484380489154"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-29T22:13:45.741Z","modified":"2025-08-09T19:53:00.777Z","2.1.1":"2024-10-29T22:13:46.047Z","3.0.0":"2024-10-29T22:14:30.643Z","3.0.1":"2024-10-29T22:18:16.582Z","2.2.0":"2024-11-01T19:44:56.697Z","2.2.1":"2024-11-02T01:36:51.654Z","2.2.2":"2024-11-02T01:39:49.901Z","4.0.0":"2025-08-09T19:53:00.571Z"},"bugs":{"url":"https://github.com/aldahick/apollo-server-integration-fastify/issues"},"author":{"name":"Oliver Plummer","email":"oliver.plummer@outlook.com"},"license":"MIT","homepage":"https://github.com/aldahick/apollo-server-integration-fastify/blob/main/readme.md","repository":{"type":"git","url":"git+https://github.com/aldahick/apollo-server-integration-fastify.git"},"description":"An Apollo Server integration for use with Fastify","maintainers":[{"name":"aldahick","email":"alex@alexhicks.net"}],"readme":"<a href='https://www.apollographql.com/'><img src='https://avatars.githubusercontent.com/u/17189275?s=200' style=\"border-radius: 6px; margin-right: 6px\" height='100' alt='Apollo Server'></a>\n<a href='https://www.fastify.io/'><img src='https://avatars.githubusercontent.com/u/24939410?s=200' style=\"border-radius: 6px\" height='100' alt='Fastify'></a>\n\n[![NPM version](https://badge.fury.io/js/@as-integrations%2Ffastify.svg)](https://www.npmjs.com/package/@as-integrations/fastify)\n[![NPM downloads](https://img.shields.io/npm/dm/@as-integrations/fastify.svg?style=flat)](https://www.npmjs.com/package/@as-integrations/fastify)\n\n# Apollo Server Integration for Fastify\n\nThis is a fork of the [@as-integrations/fastify](https://www.npmjs.com/package/@as-integrations/fastify) package, updated for Fastify ^5.0.0 by [@aldahick](https://github.com/aldahick).\n\n## **Introduction**\n\n**An Apollo Server integration for use with Fastify.**\n\nThis is a simple package that easily allows you to connect your own Fastify server implementation to an Apollo Server instance.\n\n## **Requirements**\n\n- **[Node.js v16](https://nodejs.org/)** or later\n- **[Fastify v4.4](https://www.fastify.io/)** or later\n- **[GraphQL.js v16](https://graphql.org/graphql-js/)** or later\n- **[Apollo Server v4](https://www.apollographql.com/docs/apollo-server/)** or later\n\n## **Installation**\n\n```bash\nnpm install @as-integrations/fastify @apollo/server graphql fastify\n```\n\n## **Usage**\n\nSetup [Fastify](https://www.fastify.io/) & [Apollo Server](https://www.apollographql.com/docs/apollo-server/) like you usually would and then connect the two by using the `fastifyApollo` plugin:\n\n```typescript\nimport Fastify from \"fastify\";\nimport { ApolloServer, BaseContext } from \"@apollo/server\";\nimport fastifyApollo, { fastifyApolloDrainPlugin } from \"@as-integrations/fastify\";\n// ...\n\nconst fastify = Fastify();\n\nconst apollo = new ApolloServer<BaseContext>({\n  typeDefs,\n  resolvers,\n  plugins: [fastifyApolloDrainPlugin(fastify)],\n});\n\nawait apollo.start();\n\n// ...\n\nawait fastify.register(fastifyApollo(apollo));\n```\n\nNote: **You must call and await `apollo.start()` before using the integration.**\n\nAlternatively you can use the exported function `fastifyApolloHandler` which can be passed into any [Fastify route handler](https://www.fastify.io/docs/latest/Reference/Routes/).\nThis allows you to explicitly set all routing options like the URL path and accepted methods.\n\nExamples shown below:\n\n```typescript\nimport { fastifyApolloHandler } from \"@as-integrations/fastify\";\n\n// ... setup Fastify & Apollo\n\nfastify.post(\"/graphql\", fastifyApolloHandler(apollo));\n// OR\nfastify.get(\"/api\", fastifyApolloHandler(apollo));\n// OR\nfastify.route({\n  url: \"/graphql\",\n  method: [\"POST\", \"OPTIONS\"],\n  handler: fastifyApolloHandler(apollo),\n});\n```\n\nPlease see the [example](https://github.com/apollo-server-integrations/apollo-server-integration-fastify/tree/main/example).\n\n## **Context**\n\nApollo Server v4 has moved context setup outside of the `ApolloServer` constructor.\n\nDefine your own context function and pass it in to the `context` option. The function accepts two arguments - request and reply. They are of type `FastifyRequest` and `FastifyReply` respectively. Whatever is returned from the function will be passed to the `context` argument in your resolvers.\n\nFor example:\n\n```typescript\nimport { ApolloServer } from \"@apollo/server\";\n\nimport fastifyApollo, {\n  fastifyApolloHandler,\n  ApolloFastifyContextFunction,\n} from \"@as-integrations/fastify\";\n// ...\n\ninterface MyContext {\n  authorization: JWTPayload | false;\n}\n\nconst apollo = new ApolloServer<MyContext>(...);\n\nconst myContextFunction: ApolloFastifyContextFunction<MyContext> = async (request, reply) => ({\n  authorization: await isAuthorized(request.headers.authorization),\n});\n\nawait fastify.register(fastifyApollo(apollo), {\n  context: myContextFunction,\n});\n\n// OR\n\nawait fastify.post(\"/graphql\", fastifyApolloHandler(apollo, {\n  context: myContextFunction,\n}));\n```\n\n```ts\n// Access the context in your resolvers\nexport const resolvers = {\n  Query: {\n    helloWorld: (parent, args, context, info) => {\n      if (!context.authorization) {\n        throw new Error(\"Not authorized\");\n      }\n\n      return \"Hello world :)\";\n    },\n  },\n};\n```\n\n## **API**\n\nAll options and generics are optional other than passing in the `ApolloServer` instance.\n\n### `fastifyApollo`\n\n```typescript\nfunction fastifyApollo<Context extends BaseContext = BaseContext>(\n  apollo: ApolloServer<Context>,\n): FastifyPluginAsync<ApolloFastifyPluginOptions<Context>>;\n```\n\n### `fastifyApolloHandler`\n\n```typescript\nfunction fastifyApolloHandler<Context extends BaseContext = BaseContext>(\n  apollo: ApolloServer<Context>,\n  options?: ApolloFastifyHandlerOptions<Context>,\n): RouteHandlerMethod;\n```\n\n### `ApolloFastifyContextFunction`\n\n```typescript\ntype ApolloFastifyContextFunction<Context> = (\n  request: FastifyRequest,\n  reply: FastifyReply,\n) => Promise<Context>;\n```\n\n### `ApolloFastifyHandlerOptions`\n\n```typescript\ninterface ApolloFastifyHandlerOptions<Context extends BaseContext = BaseContext> {\n  context?: ApolloFastifyContextFunction<Context>; // default: async () => ({})\n}\n```\n\n### `ApolloFastifyPluginOptions`\n\n```typescript\ninterface ApolloFastifyPluginOptions<Context extends BaseContext = BaseContext>\n  extends ApolloFastifyHandlerOptions<Context> {\n  path?: string; // default: \"/graphql\"\n  method?: HTTPMethod | HTTPMethod[]; // default: [\"GET\", \"POST\", \"OPTIONS\"]\n}\n```\n\n[`HTTPMethod`](https://www.fastify.io/docs/latest/Reference/TypeScript/#fastifyhttpmethods) is exported from Fastify.\n\n## **HTTPS/HTTP2**\n\nAll functions and types optionally allow you to pass in or infer a `Server` type from Fastify.\n\n## **Node.JS v16**\n\nPlease pass in `forceCloseConnections: true` to Fastify in combination with `fastifyApolloDrainPlugin` to correctly shutdown you're server on close and not hang incoming requests.\n\n## **Contributors**\n\n- Oliver Plummer ([olyop](https://github.com/olyop))\n- Trevor Scheer ([trevor-scheer](https://github.com/trevor-scheer))\n","readmeFilename":"readme.md"}