我找到了一些关于如何用react-apollo模拟常规查询的资源。示例代码如下:
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(),
});但是如何模拟apollo-link-state查询,即那些标记为@client的查询
发布于 2018-05-01 17:20:50
以防其他人在这里结束:我的解决方案是不嘲笑他们。因为它是本地的,所以我将其设置为与生产环境中相同的方式。
https://stackoverflow.com/questions/49988618
复制相似问题