UNPKG

@graphql-tools/federation

Version:

Useful tools to create and manipulate GraphQL schemas.

54 lines (53 loc) 2.5 kB
import { DocumentNode, GraphQLSchema } from 'graphql'; import { BatchingOptions, MergedTypeConfig, SubschemaConfig } from '@graphql-tools/delegate'; import { HTTPExecutorOptions } from '@graphql-tools/executor-http'; import { MergeFieldConfigCandidate, ValidationLevel } from '@graphql-tools/stitch'; import { type Executor } from '@graphql-tools/utils'; export declare function ensureSupergraphSDLAst(supergraphSdl: string | DocumentNode): DocumentNode; export interface FederationSubschemaConfig extends Omit<SubschemaConfig, 'executor' | 'name'> { executor: Executor; name: string; endpoint: string; } export interface GetStitchingOptionsFromSupergraphSdlOpts { supergraphSdl: string | DocumentNode; httpExecutorOpts?: Partial<HTTPExecutorOptions> | ((subgraphInfo: { name: string; endpoint?: string; }) => Partial<HTTPExecutorOptions>); onSubschemaConfig?: (subschemaConfig: FederationSubschemaConfig) => void; onMergedTypeConfig?: (typeName: string, mergedTypeConfig: MergedTypeConfig) => void; onSubgraphAST?: (name: string, subgraphAST: DocumentNode) => DocumentNode; /** * Enable query batching for all subschemas. * * @default false */ batch?: boolean; /** * Configure the query batching options for all subschemas. */ batchingOptions?: BatchingOptions; /** * Configure the batch delegation options for all merged types in all subschemas. */ batchDelegateOptions?: MergedTypeConfig['dataLoaderOptions']; } export declare function getStitchingOptionsFromSupergraphSdl(opts: GetStitchingOptionsFromSupergraphSdlOpts): { subschemas: SubschemaConfig<any, any, any, Record<string, any>>[]; typeDefs: DocumentNode; assumeValid: boolean; assumeValidSDL: boolean; typeMergingOptions: { useNonNullableFieldOnConflict: boolean; validationSettings: { validationLevel: ValidationLevel; }; fieldConfigMerger: (candidates: MergeFieldConfigCandidate<Record<string, any>>[]) => import("graphql").GraphQLFieldConfig<any, Record<string, any>, any>; }; }; export interface GetStitchedSchemaFromSupergraphSdlOpts extends GetStitchingOptionsFromSupergraphSdlOpts { supergraphSdl: string | DocumentNode; onStitchingOptions?(opts: ReturnType<typeof getStitchingOptionsFromSupergraphSdl>): void; } export declare function getStitchedSchemaFromSupergraphSdl(opts: GetStitchedSchemaFromSupergraphSdlOpts): GraphQLSchema;