Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timneutkens/micro-graphql
Example usage of GraphQL with ZEIT's micro
https://github.com/timneutkens/micro-graphql
Last synced: 4 days ago
JSON representation
Example usage of GraphQL with ZEIT's micro
- Host: GitHub
- URL: https://github.com/timneutkens/micro-graphql
- Owner: timneutkens
- Created: 2016-12-03T15:01:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-25T12:52:25.000Z (over 7 years ago)
- Last Synced: 2024-10-23T13:39:29.100Z (about 2 months ago)
- Homepage:
- Size: 1000 Bytes
- Stars: 71
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```javascript
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](https://github.com/kennetpostigo) made an excellent boilerplate based on the example above:
[hyperfuse/micro-graphql](https://github.com/hyperfuse/micro-graphql)## Alternatives
[Micro with Apollo](https://github.com/timneutkens/micro-apollo)