Skip to content

Commit

Permalink
Add support for fastify 5
Browse files Browse the repository at this point in the history
  • Loading branch information
zckrs committed Oct 4, 2024
1 parent 52783e7 commit 3ca22b2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"peerDependencies": {
"@apollo/server": "^4.0.0",
"fastify": "^4.4.0"
"fastify": "^5.0.0"
},
"devDependencies": {
"@apollo/server": "4.9.5",
Expand All @@ -74,11 +74,11 @@
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-unicorn": "48.0.1",
"fastify": "4.24.3",
"fastify": "5.0.0",
"graphql": "16.8.1",
"jest": "29.7.0",
"jest-config": "29.7.0",
"jest-junit": "16.0.0",
"jest-junit": "16.0.0",
"prettier": "3.1.0",
"rimraf": "5.0.5",
"ts-jest": "29.1.1",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This is a simple package that easily allows you to connect your own Fastify serv
- **[Fastify v4.4](https://www.fastify.io/)** or later
- **[GraphQL.js v16](https://graphql.org/graphql-js/)** or later
- **[Apollo Server v4](https://www.apollographql.com/docs/apollo-server/)** or later
- **[Fastify v5](https://www.fastify.io/)** or later

## **Installation**

Expand Down
29 changes: 28 additions & 1 deletion tests/fastify-specific.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloServer } from "@apollo/server";

import Fastify from "fastify";
import fastifyApollo, { fastifyApolloHandler } from "../src/index.js";

describe("fastify specific tests", () => {
Expand Down Expand Up @@ -33,4 +33,31 @@ describe("fastify specific tests", () => {
"You must `await server.start()` before calling `fastifyApolloHandler()`",
);
});

it("should work with fastify version 5", async () => {
const fastify = Fastify();
const apollo = new ApolloServer({
typeDefs: "type Query { hello: String }",
resolvers: {
Query: {
hello: () => "Hello world",
},
},
});

await apollo.start();

fastify.register(fastifyApollo(apollo));

const response = await fastify.inject({
method: "POST",
url: "/graphql",
payload: {
query: "{ hello }",
},
});

expect(response.statusCode).toBe(200);
expect(response.json()).toEqual({ data: { hello: "Hello world" } });
});
});

0 comments on commit 3ca22b2

Please sign in to comment.