import { ScalarsMap , ConvertNameFn , AvoidOptionalsConfig } from '../types' ; import { GraphQLObjectType , GraphQLInterfaceType , GraphQLOutputType , GraphQLNamedType } from 'graphql' ; export type PrimitiveField = { isConditional : boolean ; fieldName : string ; } ; export type PrimitiveAliasedFields = { alias : string ; fieldName : string ; } ; export type LinkField = { alias : string ; name : string ; type : string ; selectionSet : string ; } ; export type NameAndType = { name : string ; type : string ; } ; export type ProcessResult = null | Array < NameAndType | string > ; export type SelectionSetProcessorConfig = { namespacedImportName : string | null ; convertName : ConvertNameFn < any > ; enumPrefix : boolean | null ; scalars : ScalarsMap ; formatNamedField ( name , type ? , isConditional ? ) : string ; wrapTypeWithModifiers ( baseType , type ) : string ; avoidOptionals ? : AvoidOptionalsConfig ; } ; export class BaseSelectionSetProcessor < Config extends SelectionSetProcessorConfig > { constructor ( public config ) { } buildFieldsIntoObject ( allObjectsMerged ) { return `{ ${ allObjectsMerged . join ( ', ' ) } }` ; } buildSelectionSetFromStrings ( pieces ) { if ( pieces . length === 0 ) { return null ; } else if ( pieces . length === 1 ) { return pieces [ 0 ] ; } else { return `(\n  ${ pieces . join ( `\n  & ` ) }\n)` ; } } transformPrimitiveFields ( _schemaType , _fields ) { throw new Error ( `Please override "transformPrimitiveFields" as part of your BaseSelectionSetProcessor implementation!` ) ; } transformAliasesPrimitiveFields ( _schemaType , _fields ) { throw new Error ( `Please override "transformAliasesPrimitiveFields" as part of your BaseSelectionSetProcessor implementation!` ) ; } transformLinkFields ( _fields ) { throw new Error ( `Please override "transformLinkFields" as part of your BaseSelectionSetProcessor implementation!` ) ; } transformTypenameField ( _type , _name ) { throw new Error ( `Please override "transformTypenameField" as part of your BaseSelectionSetProcessor implementation!` ) ; } }