2

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?

jorgen
  • 3,425
  • 4
  • 31
  • 53

1 Answers1

1

In case anyone else ends up here: my solution was not to mock them. Since it is local I set it up the same way as in production.

jorgen
  • 3,425
  • 4
  • 31
  • 53