UNPKG

@matters/apollo-response-cache

Version:

Caching and invalidation mechanisms (plugins, directives) of Apollo GraphQL

36 lines (35 loc) 1.04 kB
import { GraphQLSchema } from 'graphql'; interface LogCacheDirectiveOption { /** * Custom function to resolve node type and id. * * ``` * // define * const typeResolver = (type: string, result: any) => { * if (['Node', 'Response'].indexOf(type) >= 0) { * return result.__type * } * return type * } * * let schema = makeExecutableSchema(..) * * schema = logCacheDirectiveTransformer(schema, 'logCache', {typeResolver, idResolver}) * * type Query { * node(input: NodeInput!): Node @logCache(type: "Node") * } * * // resolved as `Article` * const nodeResult = { id: '2', __type: 'Article' } * * ``` */ typeResolver?: (type: string, node: any) => string; idResolver?: (type: string, node: any) => string; } export declare const logCacheDirective: (directiveName?: string) => { typeDef: string; transformer: (schema: GraphQLSchema, options: LogCacheDirectiveOption) => GraphQLSchema; }; export {};