Skip to content

Commit ec94e68

Browse files
authored
examples(with-routes-graphql): update GraphQL Yoga to v3 (vercel#41478)
Update the `with-routes-graphql` example to [GraphQL Yoga](https://www.the-guild.dev/graphql/yoga-server/) new major ([migration guide](https://www.the-guild.dev/graphql/yoga-server/v3/migration/migration-from-yoga-v2)).
1 parent ce60157 commit ec94e68

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

examples/api-routes-graphql/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "next start"
77
},
88
"dependencies": {
9-
"@graphql-yoga/node": "^2.11.2",
9+
"graphql-yoga": "three",
1010
"graphql": "^16.5.0",
1111
"next": "latest",
1212
"react": "^18.2.0",

examples/api-routes-graphql/pages/api/graphql.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createServer } from '@graphql-yoga/node'
1+
import { createYoga, createSchema } from 'graphql-yoga'
22

33
const typeDefs = /* GraphQL */ `
44
type Query {
@@ -17,13 +17,13 @@ const resolvers = {
1717
},
1818
}
1919

20-
const server = createServer({
21-
schema: {
22-
typeDefs,
23-
resolvers,
24-
},
25-
endpoint: '/api/graphql',
26-
// graphiql: false // uncomment to disable GraphiQL
20+
const schema = createSchema({
21+
typeDefs,
22+
resolvers,
2723
})
2824

29-
export default server
25+
export default createYoga({
26+
schema,
27+
// Needed to be defined explicitly because our endpoint lives at a different path other than `/graphql`
28+
graphqlEndpoint: '/api/graphql',
29+
})

0 commit comments

Comments
 (0)