UNPKG

1.86 kBTypeScriptView Raw
1import { GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLOutputType } from 'graphql';
2import { AvoidOptionalsConfig, ConvertNameFn, NormalizedScalarsMap } from '../types.js';
3export type PrimitiveField = {
4 isConditional: boolean;
5 fieldName: string;
6};
7export type PrimitiveAliasedFields = {
8 alias: string;
9 fieldName: string;
10};
11export type LinkField = {
12 alias: string;
13 name: string;
14 type: string;
15 selectionSet: string;
16};
17export type NameAndType = {
18 name: string;
19 type: string;
20};
21export type ProcessResult = null | Array<NameAndType | string>;
22export type SelectionSetProcessorConfig = {
23 namespacedImportName: string | null;
24 convertName: ConvertNameFn<any>;
25 enumPrefix: boolean | null;
26 enumSuffix: boolean | null;
27 scalars: NormalizedScalarsMap;
28 formatNamedField(name: string, type?: GraphQLOutputType | GraphQLNamedType | null, isConditional?: boolean, isOptional?: boolean): string;
29 wrapTypeWithModifiers(baseType: string, type: GraphQLOutputType | GraphQLNamedType): string;
30 avoidOptionals?: AvoidOptionalsConfig | boolean;
31};
32export declare class BaseSelectionSetProcessor<Config extends SelectionSetProcessorConfig> {
33 config: Config;
34 constructor(config: Config);
35 buildFieldsIntoObject(allObjectsMerged: string[]): string;
36 buildSelectionSetFromStrings(pieces: string[]): string;
37 transformPrimitiveFields(_schemaType: GraphQLObjectType | GraphQLInterfaceType, _fields: PrimitiveField[], _unsetTypes?: boolean): ProcessResult;
38 transformAliasesPrimitiveFields(_schemaType: GraphQLObjectType | GraphQLInterfaceType, _fields: PrimitiveAliasedFields[], _unsetTypes?: boolean): ProcessResult;
39 transformLinkFields(_fields: LinkField[], _unsetTypes?: boolean): ProcessResult;
40 transformTypenameField(_type: string, _name: string): ProcessResult;
41}