graphql-mocks
Version:
Tools for setting up graphql test resolvers
33 lines (32 loc) • 1.32 kB
TypeScript
import { GraphQLSchema, GraphQLNamedType, GraphQLInputField } from 'graphql';
import { getFieldForReference } from './utils/get-field-for-reference';
import { getTypeForReference } from './utils/get-type-for-reference';
import { Highlight } from './highlight';
import { HighlightCallback } from '../resolver-map/types';
import { ObjectField } from '../types';
export declare type Reference = TypeReference | FieldReference;
export declare type FieldReference = [string, string];
export declare type TypeReference = string;
export interface Highlighter {
mark(schema: GraphQLSchema): Reference[];
}
export interface HighlighterFactory<T extends any[] = any[]> {
(...options: T): Highlighter;
}
export interface ReferencesOperation {
(source: Reference[], change: Reference[]): Reference[];
}
export declare type ReferenceMap = {
[typeName: string]: {
type: NonNullable<ReturnType<typeof getTypeForReference>>;
fields?: {
[fieldName: string]: NonNullable<ReturnType<typeof getFieldForReference>>;
};
};
};
export declare type CoercibleHighlight = Highlight | Reference[] | HighlightCallback;
export declare type WalkCallback = (options: {
reference: Reference;
type: GraphQLNamedType;
field?: ObjectField | GraphQLInputField;
}) => void | Promise<void>;