UNPKG

3.81 kBTypeScriptView Raw
1import { SelectionSetNode, FieldNode, FragmentSpreadNode, InlineFragmentNode, GraphQLNamedType, GraphQLSchema, SelectionNode, GraphQLObjectType, DirectiveNode } from 'graphql';
2import { NormalizedScalarsMap, ConvertNameFn, LoadedFragment, GetFragmentSuffixFn } from './types';
3import { BaseVisitorConvertOptions } from './base-visitor';
4import { ParsedDocumentsConfig } from './base-documents-visitor';
5import { LinkField, PrimitiveAliasedFields, PrimitiveField, BaseSelectionSetProcessor, NameAndType } from './selection-set-processor/base';
6declare type FragmentSpreadUsage = {
7 fragmentName: string;
8 typeName: string;
9 onType: string;
10 selectionNodes: Array<SelectionNode>;
11};
12export declare class SelectionSetToObject<Config extends ParsedDocumentsConfig = ParsedDocumentsConfig> {
13 protected _processor: BaseSelectionSetProcessor<any>;
14 protected _scalars: NormalizedScalarsMap;
15 protected _schema: GraphQLSchema;
16 protected _convertName: ConvertNameFn<BaseVisitorConvertOptions>;
17 protected _getFragmentSuffix: GetFragmentSuffixFn;
18 protected _loadedFragments: LoadedFragment[];
19 protected _config: Config;
20 protected _parentSchemaType?: GraphQLNamedType;
21 protected _selectionSet?: SelectionSetNode;
22 protected _primitiveFields: PrimitiveField[];
23 protected _primitiveAliasedFields: PrimitiveAliasedFields[];
24 protected _linksFields: LinkField[];
25 protected _queriedForTypename: boolean;
26 constructor(_processor: BaseSelectionSetProcessor<any>, _scalars: NormalizedScalarsMap, _schema: GraphQLSchema, _convertName: ConvertNameFn<BaseVisitorConvertOptions>, _getFragmentSuffix: GetFragmentSuffixFn, _loadedFragments: LoadedFragment[], _config: Config, _parentSchemaType?: GraphQLNamedType, _selectionSet?: SelectionSetNode);
27 createNext(parentSchemaType: GraphQLNamedType, selectionSet: SelectionSetNode): SelectionSetToObject;
28 /**
29 * traverse the inline fragment nodes recursively for collecting the selectionSets on each type
30 */
31 _collectInlineFragments(parentType: GraphQLNamedType, nodes: InlineFragmentNode[], types: Map<string, Array<SelectionNode | FragmentSpreadUsage | DirectiveNode>>): any;
32 protected _createInlineFragmentForFieldNodes(parentType: GraphQLNamedType, fieldNodes: FieldNode[]): InlineFragmentNode;
33 protected buildFragmentSpreadsUsage(spreads: FragmentSpreadNode[]): Record<string, FragmentSpreadUsage[]>;
34 protected flattenSelectionSet(selections: ReadonlyArray<SelectionNode>): Map<string, Array<SelectionNode | FragmentSpreadUsage>>;
35 private _appendToTypeMap;
36 /**
37 * mustAddEmptyObject indicates that not all possible types on a union or interface field are covered.
38 */
39 protected _buildGroupedSelections(): {
40 grouped: Record<string, string[]>;
41 mustAddEmptyObject: boolean;
42 };
43 protected selectionSetStringFromFields(fields: (string | NameAndType)[]): string | null;
44 protected buildSelectionSet(parentSchemaType: GraphQLObjectType, selectionNodes: Array<SelectionNode | FragmentSpreadUsage | DirectiveNode>): {
45 typeInfo: {
46 name: string;
47 type: string;
48 };
49 fields: string[];
50 };
51 protected buildTypeNameField(type: GraphQLObjectType, nonOptionalTypename?: boolean, addTypename?: boolean, queriedForTypename?: boolean, skipTypeNameForRoot?: boolean): {
52 name: string;
53 type: string;
54 };
55 protected getUnknownType(): string;
56 protected getEmptyObjectType(): string;
57 private getEmptyObjectTypeString;
58 transformSelectionSet(): string;
59 transformFragmentSelectionSetToTypes(fragmentName: string, fragmentSuffix: string, declarationBlockConfig: any): string;
60 protected buildFragmentTypeName(name: string, suffix: string, typeName?: string): string;
61}
62export {};