I've found some resources on how to mock regular queries with react-apollo
. An example is the code below:
import ApolloClient from 'apollo-client';
import { ApolloProvider } from 'react-apollo';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { addMockFunctionsToSchema, makeExecutableSchema } from 'graphql-tools';
const schemaString = `
type Model {
id: ID!
}
type Query {
model(modelId: ID!): Model
}
`;
const schema = makeExecutableSchema({ typeDefs: schemaString });
const mocks = {};
addMockFunctionsToSchema({ schema, mocks });
const link = new SchemaLink({ schema });
const client = new ApolloClient({
link,
cache: new InMemoryCache(),
});
But how to mock apollo-link-state
queries, i.e. those marked @client
?