UNPKG

2.77 kBTypeScriptView Raw
1import { DirectiveNode, FieldDefinitionNode, GraphQLNamedType, GraphQLObjectType, GraphQLSchema, ObjectTypeDefinitionNode } from 'graphql';
2/**
3 * Federation Spec
4 */
5export declare const federationSpec: import("graphql").DocumentNode;
6/**
7 * Adds `__resolveReference` in each ObjectType involved in Federation.
8 * @param schema
9 */
10export declare function addFederationReferencesToSchema(schema: GraphQLSchema): GraphQLSchema;
11/**
12 * Removes Federation Spec from GraphQL Schema
13 * @param schema
14 * @param config
15 */
16export declare function removeFederation(schema: GraphQLSchema): GraphQLSchema;
17interface TypeMeta {
18 hasResolveReference: boolean;
19}
20export declare class ApolloFederation {
21 private enabled;
22 private schema;
23 private providesMap;
24 protected meta: {
25 [typename: string]: TypeMeta;
26 };
27 constructor({ enabled, schema }: {
28 enabled: boolean;
29 schema: GraphQLSchema;
30 });
31 /**
32 * Excludes types definde by Federation
33 * @param typeNames List of type names
34 */
35 filterTypeNames(typeNames: string[]): string[];
36 /**
37 * Excludes `__resolveReference` fields
38 * @param fieldNames List of field names
39 */
40 filterFieldNames(fieldNames: string[]): string[];
41 /**
42 * Decides if directive should not be generated
43 * @param name directive's name
44 */
45 skipDirective(name: string): boolean;
46 /**
47 * Decides if scalar should not be generated
48 * @param name directive's name
49 */
50 skipScalar(name: string): boolean;
51 /**
52 * Decides if field should not be generated
53 * @param data
54 */
55 skipField({ fieldNode, parentType }: {
56 fieldNode: FieldDefinitionNode;
57 parentType: GraphQLNamedType;
58 }): boolean;
59 isResolveReferenceField(fieldNode: FieldDefinitionNode): boolean;
60 /**
61 * Transforms ParentType signature in ObjectTypes involved in Federation
62 * @param data
63 */
64 transformParentType({ fieldNode, parentType, parentTypeSignature, }: {
65 fieldNode: FieldDefinitionNode;
66 parentType: GraphQLNamedType;
67 parentTypeSignature: string;
68 }): string;
69 setMeta(typename: string, update: Partial<TypeMeta>): void;
70 getMeta(): {
71 [typename: string]: TypeMeta;
72 };
73 private isExternalAndNotProvided;
74 private isExternal;
75 private hasProvides;
76 private translateFieldSet;
77 private extractFieldSet;
78 private createMapOfProvides;
79}
80/**
81 * Checks if Object Type is involved in Federation. Based on `@key` directive
82 * @param node Type
83 */
84export declare function checkObjectTypeFederationDetails(node: ObjectTypeDefinitionNode | GraphQLObjectType, schema: GraphQLSchema): {
85 resolvableKeyDirectives: readonly DirectiveNode[];
86} | false;
87export {};