GraphQL Yoga is a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience.
- Easiest way to run a GraphQL server: Sensible defaults & includes everything you need with minimal setup.
- Includes Subscriptions: Built-in support for realtime GraphQL Subscriptions using WebSockets.
- Compatible: Works with all GraphQL clients (Apollo, Relay...) and fits seamless in your GraphQL workflow.
GraphQL Yoga is based on the following libraries & tools:
express
/apollo-server
: Performant, extensible web server frameworkgraphql-subscriptions
/subscriptions-transport-ws
: GraphQL subscriptions servergraphql.js
/graphql-tools
: GraphQL engine & schema helpersgraphql-playground
: Interactive GraphQL IDE
- GraphQL spec-compliant
- File uploadgit st
- GraphQL Subscriptions
- TypeScript typings
- GraphQL Playground
- Extensible via Express middlewares
- Query Performance Tracing (via Apollo Tracing)
- Accepts both
application/json
andapplication/graphql
content-type - Runs everywhere: Can be deployed via
now
,up
, AWS Lambda, Heroku etc
Install with npm
:
npm install graphql-yoga --save
Install with yarn
:
yarn add graphql-yoga
import { GraphQLServer } from 'graphql-yoga'
// ... or using `require()`
// const { GraphQLServer } = require('graphql-yoga')
const typeDefs = `
type Query {
hello(name: String): String!
}
`
const resolvers = {
Query: {
hello: (_, { name }) => `Hello ${name || 'World'}`,
},
}
const server = new GraphQLServer({ typeDefs, resolvers })
server.start(() => console.log('Server is running on localhost:4000'))
See here for more examples and use cases.
Once your graphql-yoga
server is running, you can use GraphQL Playground out of the box – typically running on localhost:4000
. (Read here for more information.)