From 0c393e694c485e12a4262192075a8cd930328eb8 Mon Sep 17 00:00:00 2001 From: Charly POLY <1252066+charlypoly@users.noreply.github.com> Date: Mon, 17 Oct 2022 19:13:48 +0200 Subject: [PATCH] examples(with-routes-graphql): update GraphQL Yoga to v3 (#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)). --- examples/api-routes-graphql/package.json | 2 +- .../api-routes-graphql/pages/api/graphql.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/api-routes-graphql/package.json b/examples/api-routes-graphql/package.json index 8efd8d1a1442c..b06243e07d643 100644 --- a/examples/api-routes-graphql/package.json +++ b/examples/api-routes-graphql/package.json @@ -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", diff --git a/examples/api-routes-graphql/pages/api/graphql.ts b/examples/api-routes-graphql/pages/api/graphql.ts index 555ea510f6771..14868f68ac7d8 100644 --- a/examples/api-routes-graphql/pages/api/graphql.ts +++ b/examples/api-routes-graphql/pages/api/graphql.ts @@ -1,4 +1,4 @@ -import { createServer } from '@graphql-yoga/node' +import { createYoga, createSchema } from 'graphql-yoga' const typeDefs = /* GraphQL */ ` type Query { @@ -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', +})