Created
July 24, 2018 09:42
-
-
Save c-jacquin/f995a793e27c631bcfc9fbde1909b585 to your computer and use it in GitHub Desktop.
Mock your graphql api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { mockServer } from 'graphql-tools'; | |
| import schema from './schema.graphql' | |
| const mockApi = mockServer(schema, { | |
| Int: () => 6, | |
| Float: () => 22.1, | |
| String: () => 'Hello', | |
| }); | |
| expressApp.post('/graphql', async (req, res) => { | |
| const { data, errors } = await mockApi.query(req.body.query, req.body.variables) | |
| res.json(data); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment