Skip to content

Commit 65eddec

Browse files
authored
Merge pull request #1231 from notrab/patch-3
feat: update Yoga usage instructions
2 parents b0ae9d0 + 9fcc25e commit 65eddec

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed
Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
11
---
22
name: graphql-yoga
3-
description: Fully-featured GraphQL Server with focus on easy setup, performance & great developer experience
3+
description: GraphQL Yoga is a batteries-included cross-platform GraphQL over HTTP spec-compliant GraphQL Server using Envelop and GraphQL Tools.
44
url: https://github.com/dotansimha/graphql-yoga
55
github: dotansimha/graphql-yoga
6-
npm: "graphql-yoga"
6+
npm: "@graphql-yoga/common"
77
---
88

9-
- Sensible defaults & includes everything you need with minimal setup.
10-
- Built-in support for GraphQL subscriptions using WebSockets.
11-
- Works with all GraphQL clients (Apollo, Relay...) and fits seamless in your GraphQL workflow.
9+
- Built around the Fetch API `Request` & `Response` objects
10+
- GraphQL over HTTP compliant
11+
- Extensible GraphQL Engine powered by Envelop
12+
- GraphQL Subscriptions over HTTP
13+
- Handle file uploads with GraphQL
14+
- Integrates with AWS Lambda, Cloudflare Workers, Deno, Express, Next.js, SvelteKit, and more.
1215

1316
To run a hello world server with graphql-yoga:
1417

1518
```bash
16-
npm install graphql-yoga
19+
npm install @graphql-yoga/node graphql
1720
```
1821

19-
Then run `node server.js` with this code in `server.js`:
22+
Then create a server using the `createServer` import:
2023

2124
```js
22-
import { GraphQLServer } from 'graphql-yoga'
23-
// ... or using "require()"
24-
// const { GraphQLServer } = require('graphql-yoga')
25-
const typeDefs = `
26-
type Query {
27-
hello(name: String): String!
28-
}
29-
`;
30-
const resolvers = {
31-
Query: {
32-
hello: (_, { name }) => `Hello ${name || 'World'}`,
25+
import { createServer } from '@graphql-yoga/node'
26+
27+
const server = createServer({
28+
schema: {
29+
typeDefs: /* GraphQL */ `
30+
type Query {
31+
hello: String
32+
}
33+
`,
34+
resolvers: {
35+
Query: {
36+
hello: () => 'Hello Hello Hello',
37+
},
38+
},
3339
},
34-
};
35-
const server = new GraphQLServer({ typeDefs, resolvers })
36-
server.start(() => console.log('Server is running on localhost:4000'))
40+
})
41+
42+
server.start()
3743
```
44+
45+
Depending on your deployment target, you may need to use an additional library. See the [documentation](https://www.graphql-yoga.com/docs) for further details.

0 commit comments

Comments
 (0)