Skip to content

Commit d7c25fd

Browse files
committed
small documentation improvements
1 parent 8443de8 commit d7c25fd

File tree

10 files changed

+48
-12
lines changed

10 files changed

+48
-12
lines changed

examples/nextjs-edge/pages/api/graphql.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
21
import { createYoga, createSchema } from 'graphql-yoga'
3-
import { NextRequest, NextFetchEvent } from 'next/server'
42

53
// Docs: https://vercel.com/docs/concepts/functions/edge-functions
64

website/src/pages/docs/integrations/_meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"integration-with-fastify": "Fastify",
77
"integration-with-koa": "Koa",
88
"integration-with-nestjs": "NestJS",
9-
"integration-with-nextjs": "Next.js",
9+
"integration-with-nextjs": "Next.js (Vercel)",
1010
"integration-with-sveltekit": "SvelteKit",
1111
"integration-with-bun": "Bun",
1212
"integration-with-uwebsockets": "uWebSockets",
13+
"integration-with-gcp": "Google Cloud Platform (GCP)",
1314
"z-other-environments": "Other Environments"
1415
}

website/src/pages/docs/integrations/integration-with-aws-lambda.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AWS Lambda is a serverless computing platform that makes it easy to build applic
66

77
## Installation
88

9-
<PackageCmd packages={['graphql', 'aws-lambda', 'graphql-yoga']} />
9+
<PackageCmd packages={['graphql aws-lambda graphql-yoga']} />
1010

1111
## Example
1212

website/src/pages/docs/integrations/integration-with-bun.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ So the configuration is really simple like any other JS runtime with Yoga;
88

99
## Installation
1010

11-
<PackageCmd packages={['graphql', 'graphql-yoga']} />
11+
<PackageCmd packages={['graphql graphql-yoga']} />
1212

1313
## Usage
1414

website/src/pages/docs/integrations/integration-with-cloudflare-workers.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You will want to use the package `graphql-yoga` which has an agnostic HTTP handl
1717

1818
## Installation
1919

20-
<PackageCmd packages={['graphql', 'graphql-yoga']} />
20+
<PackageCmd packages={['graphql graphql-yoga']} />
2121

2222
## Example with regular `fetch` event listener
2323

website/src/pages/docs/integrations/integration-with-express.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can easily integrate GraphQL Yoga into your Express application with a few l
1212

1313
## Installation
1414

15-
<PackageCmd packages={['express', 'graphql', 'graphql-yoga']} />
15+
<PackageCmd packages={['express graphql graphql-yoga']} />
1616

1717
## Example
1818

website/src/pages/docs/integrations/integration-with-fastify.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ So you can benefit from the powerful plugins of Fastify ecosystem with GraphQL Y
1010

1111
## Installation
1212

13-
<PackageCmd packages={['fastify', 'graphql', 'graphql-yoga']} />
13+
<PackageCmd packages={['fastify graphq graphql-yoga']} />
1414

1515
## Example
1616

website/src/pages/docs/integrations/integration-with-gcp.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ It is easy to use GraphQL Yoga with GCP.
77

88
## Installation
99

10-
<PackageCmd packages={['graphql', 'graphql-yoga']} />
10+
<PackageCmd packages={['graphql graphql-yoga']} />
1111

1212
## Usage
1313

website/src/pages/docs/integrations/integration-with-koa.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GraphQL Yoga can be integrated easily as a route to the existing Koa application
77

88
## Installation
99

10-
<PackageCmd packages={['koa', 'graphql', 'graphql-yoga']} />
10+
<PackageCmd packages={['koa graphql graphql-yoga']} />
1111

1212
## Example
1313

website/src/pages/docs/integrations/integration-with-nextjs.mdx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { PackageCmd } from '@theguild/components'
1+
import { PackageCmd, Callout } from '@theguild/components'
22

33
# Integration with Next.js
44

55
[Next.js](https://nextjs.org) is a web framework that allows you to build websites very quickly and GraphQL Yoga can be integrated with Next.js easily as [an API Route](https://nextjs.org/docs/api-routes/api-middlewares).
66

77
## Installation
88

9-
<PackageCmd packages={['graphql', 'graphql-yoga']} />
9+
<PackageCmd packages={['graphql graphql-yoga']} />
1010

1111
## Example
1212

@@ -47,6 +47,43 @@ export default createYoga<{
4747

4848
> You can also check a full example on our GitHub repository [here](https://github.com/dotansimha/graphql-yoga/tree/v3/examples/nextjs)
4949
50+
## Edge Function
51+
52+
<Callout>
53+
Edge functions is a feature of the Vercel platform and not available when
54+
using Next.js as a standalone server. Learn more about edge functions on the
55+
[Vercel documentation](https://nextjs.org/docs/api-routes/edge-functions).
56+
</Callout>
57+
58+
For edge functions you need to adjust the `config` object to include the `runtime` property with the value `"edge"` and export `yoga.handleRequest` instead of `yoga`.
59+
60+
```ts filename="pages/api/graphql.ts" {2-5,24}
61+
import { createYoga, createSchema } from 'graphql-yoga'
62+
63+
export const config = {
64+
runtime: 'edge'
65+
}
66+
67+
const yoga = createYoga({
68+
graphqlEndpoint: '/api/graphql',
69+
schema: createSchema({
70+
typeDefs: /* GraphQL */ `
71+
type Query {
72+
greetings: String
73+
}
74+
`,
75+
resolvers: {
76+
Query: {
77+
greetings: () =>
78+
'This is the `greetings` field of the root `Query` type'
79+
}
80+
}
81+
})
82+
})
83+
84+
export default yoga.handleRequest
85+
```
86+
5087
## WebSockets for subscriptions
5188

5289
WebSockets cannot be used with [Next.js API Routes](https://nextjs.org/docs/api-routes/introduction), we therefore have to create a [custom Next.js server](https://nextjs.org/docs/advanced-features/custom-server) that will serve the GraphQL API, WebSockets and the rest of Next.js content.

0 commit comments

Comments
 (0)