Skip to content

Commit

Permalink
examples(with-routes-graphql): update GraphQL Yoga to v3 (vercel#41478)
Browse files Browse the repository at this point in the history
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)).
  • Loading branch information
charlypoly authored and Kikobeats committed Oct 24, 2022
1 parent 9d0e29d commit 0c393e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/api-routes-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"start": "next start"
},
"dependencies": {
"@graphql-yoga/node": "^2.11.2",
"graphql-yoga": "three",
"graphql": "^16.5.0",
"next": "latest",
"react": "^18.2.0",
Expand Down
18 changes: 9 additions & 9 deletions examples/api-routes-graphql/pages/api/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createServer } from '@graphql-yoga/node'
import { createYoga, createSchema } from 'graphql-yoga'

const typeDefs = /* GraphQL */ `
type Query {
Expand All @@ -17,13 +17,13 @@ const resolvers = {
},
}

const server = createServer({
schema: {
typeDefs,
resolvers,
},
endpoint: '/api/graphql',
// graphiql: false // uncomment to disable GraphiQL
const schema = createSchema({
typeDefs,
resolvers,
})

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

0 comments on commit 0c393e6

Please sign in to comment.