Skip to content

Instantly share code, notes, and snippets.

@ananth99
Created July 24, 2018 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ananth99/115eb62b74e8f596def8f4bb5adbeeea to your computer and use it in GitHub Desktop.
Save ananth99/115eb62b74e8f596def8f4bb5adbeeea to your computer and use it in GitHub Desktop.
// mocked schema for tests.
import { ApolloClient, InMemoryCache } from 'apollo-boost';
import { SchemaLink } from 'apollo-link-schema';
import {
addMockFunctionsToSchema,
} from 'graphql-tools';
import { buildClientSchema } from 'graphql';
import * as introspectionResult from './schema.json';
import mocks from '../mocks';
const schema = buildClientSchema(introspectionResult);
addMockFunctionsToSchema({
schema,
mocks,
preserveResolvers: false,
});
export const mockedClient = new ApolloClient({
cache: new InMemoryCache(),
link: new SchemaLink({ schema }),
});
export default mockedClient;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment