UNPKG

1.33 kBTypeScriptView Raw
1import { IResolvers, Maybe } from '@graphql-tools/utils';
2/**
3 * Additional options for merging resolvers
4 */
5export interface MergeResolversOptions {
6 exclusions?: string[];
7}
8/**
9 * Deep merges multiple resolver definition objects into a single definition.
10 * @param resolversDefinitions Resolver definitions to be merged
11 * @param options Additional options
12 *
13 * ```js
14 * const { mergeResolvers } = require('@graphql-tools/merge');
15 * const clientResolver = require('./clientResolver');
16 * const productResolver = require('./productResolver');
17 *
18 * const resolvers = mergeResolvers([
19 * clientResolver,
20 * productResolver,
21 * ]);
22 * ```
23 *
24 * If you don't want to manually create the array of resolver objects, you can
25 * also use this function along with loadFiles:
26 *
27 * ```js
28 * const path = require('path');
29 * const { mergeResolvers } = require('@graphql-tools/merge');
30 * const { loadFilesSync } = require('@graphql-tools/load-files');
31 *
32 * const resolversArray = loadFilesSync(path.join(__dirname, './resolvers'));
33 *
34 * const resolvers = mergeResolvers(resolversArray)
35 * ```
36 */
37export declare function mergeResolvers<TSource, TContext>(resolversDefinitions: Maybe<IResolvers<TSource, TContext>> | Maybe<Maybe<IResolvers<TSource, TContext>>[]>, options?: MergeResolversOptions): IResolvers<TSource, TContext>;