Skip to content

Commit 792d2ec

Browse files
committed
📘 doc: update graphql yoga config
1 parent 5992f08 commit 792d2ec

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

bun.lockb

95.4 KB
Binary file not shown.

docs/plugins/graphql-yoga.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,43 @@ This plugin integrate GraphQL yoga with Elysia
1919

2020
Install with:
2121
```bash
22-
bun add graphql graphql-yoga @elysiajs/graphql-yoga
22+
bun add @elysiajs/graphql-yoga
2323
```
2424

2525
Then use it:
2626
```typescript
2727
import { Elysia } from 'elysia'
2828
import { yoga } from '@elysiajs/graphql-yoga'
2929

30-
import { createYoga, createSchema } from 'graphql-yoga'
31-
3230
const app = new Elysia()
3331
.use(
3432
yoga({
35-
yoga: createYoga({
36-
schema: createSchema({
37-
typeDefs: `
38-
type Query {
39-
hi: String
40-
}
41-
`,
42-
resolvers: {
43-
Query: {
44-
hi: () => 'Hi from Elysia'
45-
}
33+
typeDefs: /* GraphQL */`
34+
type Query {
35+
hi: String
36+
}
37+
`,
38+
resolvers: {
39+
Query: {
40+
hi: () => 'Hello from Elysia'
4641
}
47-
})
42+
}
4843
})
4944
)
5045
.listen(8080)
5146
```
5247

5348
Accessing `/swagger` would show you a Swagger endpoint with generated endpoint from Elysia server.
5449

55-
## Config
56-
Below is a config which accepted by the plugin
50+
optional: you can install custom version of optional peer dependencies as well:
51+
```bash
52+
bun add graphql graphql-yoga
53+
```
5754

58-
### yoga
59-
GraphQL Yoga instance.
55+
## Config
56+
This plugin extends [GraphQL Yoga's createYoga options, please refers to the GraphQL Yoga documentation](https://the-guild.dev/graphql/yoga-server/docs) with inlining `schema` config to root.
6057

61-
Please refers to the [GraphQL Yoga documentation](https://the-guild.dev/graphql/yoga-server/docs).
58+
Below is a config which accepted by the plugin
6259

6360
### path
6461
@default `/graphql`

0 commit comments

Comments
 (0)