Last active
November 22, 2018 10:54
-
-
Save barsumek/d795a4bcb7d3f9c5c3944a4acbec2d94 to your computer and use it in GitHub Desktop.
Detox your GraphQL: Mock schema
This file contains 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
const { ApolloServer } = require("apollo-server-express"); | |
const { buildClientSchema } = require("graphql"); | |
const { resolvers } = require("./schema"); | |
const introspectedSchema = require("./schemaExample.json"); | |
const PORT = 8089; | |
function createServerWithMockedSchema(customMocks = {}) { | |
const schema = buildClientSchema(introspectedSchema); | |
const server = new ApolloServer({ | |
schema: schema, | |
resolvers: resolvers, | |
mocks: customMocks, | |
playground: { | |
endpoint: `http://localhost:${PORT}/graphql` | |
} | |
}); | |
return server; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment