@graphql-tools/mock

Classes

Interfaces

Type aliases

Functions

Type aliases

IMockFn

Ƭ IMockFn: GraphQLFieldResolver‹any, any›

Defined in packages/mock/src/types.ts:6

Functions

addMocksToSchema

addMocksToSchema(__namedParameters: object): GraphQLSchema

Defined in packages/mock/src/mocking.ts:82

Given an instance of GraphQLSchema and a mock object, returns a new schema that can return mock data for any valid query that is sent to the server.

Parameters:

__namedParameters: object

NameTypeDefault
mocksIMocks-
preserveResolversbooleanfalse
schemaGraphQLSchema‹›-

Returns: GraphQLSchema


mockServer

mockServer(schema: GraphQLSchema | ITypeDefinitions, mocks: IMocks, preserveResolvers: boolean): IMockServer

Defined in packages/mock/src/mocking.ts:39

A convenience wrapper on top of addMocksToSchema. It adds your mock resolvers to your schema and returns a client that will correctly execute your query with variables. Note: when executing queries from the returned server, context and root will both equal {}.

Parameters:

NameTypeDefaultDescription
schemaGraphQLSchema | ITypeDefinitions-The schema to which to add mocks. This can also be a set of type definitions instead.
mocksIMocks-The mocks to add to the schema.
preserveResolversbooleanfalseSet to true to prevent existing resolvers from being overwritten to provide mock data. This can be used to mock some parts of the server and not others.

Returns: IMockServer