graphql-yoga
```js const { GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql') const { createServer } = require('graphql-yoga')
Last updated 3 years ago by dotansimha .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install graphql-yoga 
SYNC missed versions from official npm registry.

@graphql-yoga

const { GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql')
const { createServer } = require('graphql-yoga')

const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'Query',
    fields: () => ({
      song: {
        type: new GraphQLObjectType({
          name: 'Song',
          fields: () => ({
            firstVerse: {
              type: GraphQLString,
              resolve: (_, __, { logger }) => {
                logger.info('I can even use the same logger!')
                return "Now I know my ABC's."
              },
            },
            secondVerse: {
              type: GraphQLString,
              resolve: () =>
                new Promise((resolve) =>
                  setTimeout(
                    () => resolve("Next time won't you sing with me?"),
                    5000,
                  ),
                ),
            },
          }),
        }),
        resolve: () => ({}),
      },
    }),
  }),
})

const server = createServer({ schema })
server.start()

Current Tags

  • 5.6.1-alpha-20240701221432-d2a40ed6                                ...           alpha (4 months ago)
  • 2.0.0-beta.8                                ...           beta (3 years ago)
  • 2.13.7-canary-4a8cc11.0                                ...           canary (2 years ago)
  • 5.6.0                                ...           latest (4 months ago)
  • 5.4.0-rc-20240603095956-b14bcd26                                ...           rc (5 months ago)
  • 3.0.0-next.12                                ...           three (2 years ago)

3666 Versions

Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (9)
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE