└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Micro-graphql 2 | Example usage of GraphQL with ZEIT's micro 3 | 4 | ## Installation 5 | 6 | `npm install -g micro` or `yarn global add micro` 7 | 8 | ## Usage 9 | 10 | Create an `index.js` file with the following contents: 11 | 12 | ```javascript 13 | const { buildSchema } = require('graphql') 14 | const graphqlHTTP = require('express-graphql') 15 | 16 | const schema = buildSchema(` 17 | type Query { 18 | hello: String 19 | } 20 | `) 21 | 22 | const rootValue = { 23 | hello: () => 'Hello world' 24 | } 25 | 26 | module.exports = graphqlHTTP({ 27 | schema, 28 | rootValue, 29 | graphiql: true 30 | }) 31 | ``` 32 | 33 | Then run 34 | `micro index.js` 35 | 36 | ## Boilerplates 37 | 38 | [Kennet Postigo](https://github.com/kennetpostigo) made an excellent boilerplate based on the example above: 39 | [hyperfuse/micro-graphql](https://github.com/hyperfuse/micro-graphql) 40 | 41 | ## Alternatives 42 | 43 | [Micro with Apollo](https://github.com/timneutkens/micro-apollo) 44 | 45 | --------------------------------------------------------------------------------