Skip to content

Commit 35900a8

Browse files
committed
Add graphql-yoga code sample to code
1 parent a9312f7 commit 35900a8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

site/code/index.html.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,43 @@ app.listen({ port: 4000 }, () =>
335335
336336
Apollo Server also supports all Node.js HTTP server frameworks: Express, Connect, HAPI, Koa and NestJs.
337337
338+
#### [graphql-yoga](https://github.com/prisma-labs/graphql-yoga) ([github](https://github.com/apollographql/apollo-server)) ([npm](https://www.npmjs.com/package/graphql-yoga))
339+
340+
Fully-featured GraphQL Server with focus on easy setup, performance & great developer experience
341+
342+
- Sensible defaults & includes everything you need with minimal setup.
343+
- Built-in support for GraphQL subscriptions using WebSockets.
344+
- Works with all GraphQL clients (Apollo, Relay...) and fits seamless in your GraphQL workflow.
345+
346+
To run a hello world server with graphql-yoga:
347+
348+
\`\`\`bash
349+
npm install graphql-yoga
350+
\`\`\`
351+
352+
Then run \`node server.js\` with this code in \`server.js\`:
353+
354+
\`\`\`js
355+
import { GraphQLServer } from 'graphql-yoga'
356+
// ... or using "require()"
357+
// const { GraphQLServer } = require('graphql-yoga')
358+
359+
const typeDefs = \`
360+
type Query {
361+
hello(name: String): String!
362+
}
363+
\`;
364+
365+
const resolvers = {
366+
Query: {
367+
hello: (_, { name }) => \`Hello \${name || 'World'}\`,
368+
},
369+
};
370+
371+
const server = new GraphQLServer({ typeDefs, resolvers })
372+
server.start(() => console.log('Server is running on localhost:4000'))
373+
\`\`\`
374+
338375
### Kotlin
339376
340377
- [graphql-kotlin](https://github.com/ExpediaGroup/graphql-kotlin/): A set of libraries for running GraphQL server in Kotlin.

0 commit comments

Comments
 (0)