Example usage of GraphQL with ZEIT's micro
npm install -g micro
or yarn global add micro
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
Kennet Postigo made an excellent boilerplate based on the example above: hyperfuse/micro-graphql