Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 807 Bytes

README.md

File metadata and controls

44 lines (30 loc) · 807 Bytes

Micro-graphql

Example usage of GraphQL with ZEIT's micro

Installation

npm install -g micro or yarn global add micro

Usage

Create an index.js file with the following contents:

const { buildSchema } = require('graphql')
const graphqlHTTP = require('express-graphql')

const schema = buildSchema(`
  type Query {
    hello: String
  }
`)

const rootValue = {
  hello: () => 'Hello world'
}

module.exports = graphqlHTTP({
  schema,
  rootValue,
  graphiql: true
})

Then run micro index.js

Boilerplates

Kennet Postigo made an excellent boilerplate based on the example above: hyperfuse/micro-graphql

Alternatives

Micro with Apollo