@graphql-codegen/plugin-helpers
Version:
GraphQL Code Generator common utils and types
88 lines (87 loc) • 2.77 kB
text/typescript
import { DirectiveNode, FieldDefinitionNode, GraphQLNamedType, GraphQLObjectType, GraphQLSchema, ObjectTypeDefinitionNode } from 'graphql';
/**
* Federation Spec
*/
export declare const federationSpec: import("graphql").DocumentNode;
/**
* Adds `__resolveReference` in each ObjectType involved in Federation.
* @param schema
*/
export declare function addFederationReferencesToSchema(schema: GraphQLSchema): GraphQLSchema;
/**
* Removes Federation Spec from GraphQL Schema
* @param schema
* @param config
*/
export declare function removeFederation(schema: GraphQLSchema): GraphQLSchema;
interface TypeMeta {
hasResolveReference: boolean;
}
export declare class ApolloFederation {
private enabled;
private schema;
private providesMap;
protected meta: {
[typename: string]: TypeMeta;
};
constructor({ enabled, schema }: {
enabled: boolean;
schema: GraphQLSchema;
});
/**
* Excludes types definde by Federation
* @param typeNames List of type names
*/
filterTypeNames(typeNames: string[]): string[];
/**
* Excludes `__resolveReference` fields
* @param fieldNames List of field names
*/
filterFieldNames(fieldNames: string[]): string[];
/**
* Decides if directive should not be generated
* @param name directive's name
*/
skipDirective(name: string): boolean;
/**
* Decides if scalar should not be generated
* @param name directive's name
*/
skipScalar(name: string): boolean;
/**
* Decides if field should not be generated
* @param data
*/
skipField({ fieldNode, parentType }: {
fieldNode: FieldDefinitionNode;
parentType: GraphQLNamedType;
}): boolean;
isResolveReferenceField(fieldNode: FieldDefinitionNode): boolean;
/**
* Transforms ParentType signature in ObjectTypes involved in Federation
* @param data
*/
transformParentType({ fieldNode, parentType, parentTypeSignature, }: {
fieldNode: FieldDefinitionNode;
parentType: GraphQLNamedType;
parentTypeSignature: string;
}): string;
setMeta(typename: string, update: Partial<TypeMeta>): void;
getMeta(): {
[typename: string]: TypeMeta;
};
private isExternalAndNotProvided;
private isExternal;
private hasProvides;
private translateFieldSet;
private extractFieldSet;
private createMapOfProvides;
}
/**
* Checks if Object Type is involved in Federation. Based on `@key` directive
* @param node Type
*/
export declare function checkObjectTypeFederationDetails(node: ObjectTypeDefinitionNode | GraphQLObjectType, schema: GraphQLSchema): {
resolvableKeyDirectives: readonly DirectiveNode[];
} | false;
export {};