Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 524 Bytes

File metadata and controls

32 lines (25 loc) · 524 Bytes

GraphQL Server

Install graphql-yoga

npm i graphql-yoga

In the server.js

import { GraphQLServer } from 'graphql-yoga'

// Type definition(Schema)
const typeDefs = `
  type Query {
    hello: String!
  }
`

// Resolvers
const resolvers = {
  Query: {
    hello() { return 'hello world' },
  }
}

const server = new GraphQLServer({ typeDefs, resolvers })
server.start({ port: 8000 }, ({ port }) => {
  console.log(`Server is up on ${port}...`)
})