4
4
5
5
Fully-featured GraphQL Server with focus on easy setup, performance & great developer experience
6
6
7
- [ Docs] ( https://www.graphql-yoga.com/docs )
7
+ [ Docs] ( https://www.the-guild.dev/graphql/yoga-server/v3 )
8
8
9
9
### Installation
10
10
11
11
``` shell
12
- npm i @ graphql-yoga/node graphql
12
+ yarn add graphql-yoga graphql
13
13
```
14
14
15
15
### Quickstart
16
16
17
- You will need to provide schema to Yoga, either by an existing executable schema, or by providing your type definitions and resolver map :
17
+ Make a schema, create Yoga and start a Node server with it :
18
18
19
19
``` ts
20
- import { createServer } from ' @graphql-yoga/node'
20
+ import { createSchema , createYoga } from ' graphql-yoga'
21
+ import { createServer } from ' http'
21
22
22
- const server = createServer ({
23
- schema: {
23
+ const yoga = createYoga ({
24
+ schema: createSchema ( {
24
25
typeDefs: /* GraphQL */ `
25
26
type Query {
26
27
hello: String
@@ -31,10 +32,12 @@ const server = createServer({
31
32
hello : () => ' Hello from Yoga!' ,
32
33
},
33
34
},
34
- },
35
+ }) ,
35
36
})
36
37
37
- server .start ()
38
+ const server = createServer (yoga )
39
+
40
+ server .listen (4000 )
38
41
```
39
42
40
43
## Overview
@@ -51,7 +54,7 @@ server.start()
51
54
- TypeScript
52
55
- File upload with [ GraphQL Multipart Request spec] ( https://github.com/jaydenseric/graphql-multipart-request-spec )
53
56
- Realtime capabilities
54
- - Accepts ` application/json ` , ` application/graphql+json ` , ` application/x-www-form-urlencoded ` , ` application/graphql ` and ` multipart/formdata ` content-types
57
+ - Accepts ` application/json ` , ` application/graphql-response+json ` , ` application/graphql +json` , ` application/x-www-form-urlencoded ` , ` application/graphql ` and ` multipart/formdata ` content-types
55
58
- Supports [ ESM] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules )
56
59
- Runs everywhere: Can be deployed via ` now ` , ` up ` , AWS Lambda, Heroku etc.
57
60
0 commit comments