graphql-yoga

Rewrite of a fully-featured GraphQL Server with focus on easy setup, perfor...

README


GraphQL Yoga


Fully-featured GraphQL Server with focus on easy setup, performance & great developer experience


Installation


  1. ``` sh
  2. npm i @graphql-yoga/node graphql
  3. ```

Quickstart


You will need to provide schema to Yoga, either by an existing executable schema, or by providing your type definitions and resolver map:

  1. ```ts
  2. import { createServer } from '@graphql-yoga/node'

  3. const server = createServer({
  4.   schema: {
  5.     typeDefs: /* GraphQL */ `
  6.       type Query {
  7.         hello: String
  8.       }
  9.     `,
  10.     resolvers: {
  11.       Query: {
  12.         hello: () => 'Hello from Yoga!',
  13.       },
  14.     },
  15.   },
  16. })

  17. server.start()
  18. ```

Overview


- Easiest way to run a GraphQL server: Sensible defaults & includes everything you need with minimal setup (we also export a platform/env-agnostic handler so you can build your own wrappers easily).
- Includes Subscriptions: Built-in support for GraphQL subscriptions using [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events).
- Compatible: Works with all GraphQL clients (Apollo, Relay, Urql...) and fits seamless in your GraphQL workflow.
- WHATWG Fetch API: the core package depends on WHATWG Fetch API so it can run and deploy on any environment (Serverless, Workers, Deno, Node).
- Easily Extendable: New GraphQL-Yoga support all [envelop](https://www.envelop.dev) plugins.

Features


- TypeScript
- Realtime capabilities
- Accepts application/json, application/graphql+json, application/x-www-form-urlencoded, application/graphql and multipart/formdata content-types
- Supports ESM
- Runs everywhere: Can be deployed via now, up, AWS Lambda, Heroku etc.

Contributing


If this is your first time contributing to this project, please do read our Contributor Workflow Guide before you get started off.

Feel free to open issues and pull requests. We're always welcome support from the community.

Code of Conduct


Help us keep Yoga open and inclusive. Please read and follow our [
of Conduct](https://github.com/the-guild-org/Stack/blob/master/CODE_OF_CONDUCT.md) as adopted from Contributor Covenant

License

GitHub license

MIT