UNPKG

2.48 kBTypeScriptView Raw
1import { GraphQLSchema, FragmentDefinitionNode, GraphQLObjectType, SelectionSetNode, FieldNode, FragmentSpreadNode, InlineFragmentNode } from 'graphql';
2export interface PatchFields {
3 label: string | undefined;
4 fields: Map<string, Array<FieldNode>>;
5}
6export interface FieldsAndPatches {
7 fields: Map<string, Array<FieldNode>>;
8 patches: Array<PatchFields>;
9}
10/**
11 * Given a selectionSet, collects all of the fields and returns them.
12 *
13 * CollectFields requires the "runtime type" of an object. For a field that
14 * returns an Interface or Union type, the "runtime type" will be the actual
15 * object type returned by that field.
16 *
17 */
18export declare function collectFields<TVariables = any>(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: TVariables, runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode): FieldsAndPatches;
19/**
20 * Determines if a field should be included based on the `@include` and `@skip`
21 * directives, where `@skip` has higher precedence than `@include`.
22 */
23export declare function shouldIncludeNode(variableValues: any, node: FragmentSpreadNode | FieldNode | InlineFragmentNode): boolean;
24/**
25 * Determines if a fragment is applicable to the given type.
26 */
27export declare function doesFragmentConditionMatch(schema: GraphQLSchema, fragment: FragmentDefinitionNode | InlineFragmentNode, type: GraphQLObjectType): boolean;
28/**
29 * Implements the logic to compute the key of a given field's entry
30 */
31export declare function getFieldEntryKey(node: FieldNode): string;
32/**
33 * Returns an object containing the `@defer` arguments if a field should be
34 * deferred based on the experimental flag, defer directive present and
35 * not disabled by the "if" argument.
36 */
37export declare function getDeferValues(variableValues: any, node: FragmentSpreadNode | InlineFragmentNode): undefined | {
38 label: string | undefined;
39};
40/**
41 * Given an array of field nodes, collects all of the subfields of the passed
42 * in fields, and returns them at the end.
43 *
44 * CollectSubFields requires the "return type" of an object. For a field that
45 * returns an Interface or Union type, the "return type" will be the actual
46 * object type returned by that field.
47 *
48 */
49export declare const collectSubFields: (schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: {
50 [variable: string]: unknown;
51}, returnType: GraphQLObjectType, fieldNodes: Array<FieldNode>) => FieldsAndPatches;