Skip to content

Instantly share code, notes, and snippets.

@c-jacquin
Created July 24, 2018 09:42
Show Gist options
  • Select an option

  • Save c-jacquin/f995a793e27c631bcfc9fbde1909b585 to your computer and use it in GitHub Desktop.

Select an option

Save c-jacquin/f995a793e27c631bcfc9fbde1909b585 to your computer and use it in GitHub Desktop.
Mock your graphql api
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