UNPKG

4.85 kBTypeScriptView Raw
1import { FieldNode, FragmentSpreadNode, GraphQLInputObjectType, GraphQLNamedType, GraphQLObjectType, GraphQLOutputType, GraphQLSchema, InlineFragmentNode, NamedTypeNode, NameNode, SelectionNode, SelectionSetNode, StringValueNode, TypeNode, DirectiveNode } from 'graphql';
2import { RawConfig } from './base-visitor.js';
3import { NormalizedScalarsMap, ParsedScalarsMap, ScalarsMap, FragmentDirectives } from './types.js';
4export declare const getConfigValue: <T = any>(value: T, defaultValue: T) => T;
5export declare function quoteIfNeeded(array: string[], joinWith?: string): string;
6export declare function block(array: any): string;
7export declare function wrapWithSingleQuotes(value: string | number | NameNode, skipNumericCheck?: boolean): string;
8export declare function breakLine(str: string): string;
9export declare function indent(str: string, count?: number): string;
10export declare function indentMultiline(str: string, count?: number): string;
11export interface DeclarationBlockConfig {
12 blockWrapper?: string;
13 blockTransformer?: (block: string) => string;
14 enumNameValueSeparator?: string;
15 ignoreExport?: boolean;
16}
17export declare function transformComment(comment: string | StringValueNode, indentLevel?: number, disabled?: boolean): string;
18export declare class DeclarationBlock {
19 private _config;
20 _decorator: any;
21 _export: boolean;
22 _name: any;
23 _kind: any;
24 _methodName: any;
25 _content: any;
26 _block: any;
27 _nameGenerics: any;
28 _comment: any;
29 _ignoreBlockWrapper: boolean;
30 constructor(_config: DeclarationBlockConfig);
31 withDecorator(decorator: string): DeclarationBlock;
32 export(exp?: boolean): DeclarationBlock;
33 asKind(kind: string): DeclarationBlock;
34 withComment(comment: string | StringValueNode | null, disabled?: boolean): DeclarationBlock;
35 withMethodCall(methodName: string, ignoreBlockWrapper?: boolean): DeclarationBlock;
36 withBlock(block: string): DeclarationBlock;
37 withContent(content: string): DeclarationBlock;
38 withName(name: string | NameNode, generics?: string | null): DeclarationBlock;
39 get string(): string;
40}
41export declare function getBaseTypeNode(typeNode: TypeNode): NamedTypeNode;
42export declare function convertNameParts(str: string, func: (str: string) => string, removeUnderscore?: boolean): string;
43export declare function buildScalarsFromConfig(schema: GraphQLSchema | undefined, config: RawConfig, defaultScalarsMapping?: NormalizedScalarsMap, defaultScalarType?: string): ParsedScalarsMap;
44export declare function buildScalars(schema: GraphQLSchema | undefined, scalarsMapping: ScalarsMap, defaultScalarsMapping?: NormalizedScalarsMap, defaultScalarType?: string | null): ParsedScalarsMap;
45export declare function getRootTypeNames(schema: GraphQLSchema): string[];
46export declare function stripMapperTypeInterpolation(identifier: string): string;
47export declare const OMIT_TYPE = "export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;";
48export declare const REQUIRE_FIELDS_TYPE = "export type RequireFields<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> };";
49/**
50 * merge selection sets into a new selection set without mutating the inputs.
51 */
52export declare function mergeSelectionSets(selectionSet1: SelectionSetNode, selectionSet2: SelectionSetNode): SelectionSetNode;
53export declare const getFieldNodeNameValue: (node: FieldNode) => string;
54export declare function separateSelectionSet(selections: ReadonlyArray<SelectionNode>): {
55 fields: (FieldNode & FragmentDirectives)[];
56 spreads: FragmentSpreadNode[];
57 inlines: InlineFragmentNode[];
58};
59export declare function getPossibleTypes(schema: GraphQLSchema, type: GraphQLNamedType): GraphQLObjectType[];
60export declare function hasConditionalDirectives(field: FieldNode): boolean;
61export declare function hasIncrementalDeliveryDirectives(directives: DirectiveNode[]): boolean;
62type WrapModifiersOptions = {
63 wrapOptional(type: string): string;
64 wrapArray(type: string): string;
65};
66export declare function wrapTypeWithModifiers(baseType: string, type: GraphQLOutputType | GraphQLNamedType, options: WrapModifiersOptions): string;
67export declare function removeDescription<T extends {
68 description?: StringValueNode;
69}>(nodes: readonly T[]): (T & {
70 description: any;
71})[];
72export declare function wrapTypeNodeWithModifiers(baseType: string, typeNode: TypeNode): string;
73export declare function isOneOfInputObjectType(namedType: GraphQLNamedType | null | undefined): namedType is GraphQLInputObjectType;
74export declare function groupBy<T>(array: Array<T>, key: (item: T) => string | number): {
75 [key: string]: Array<T>;
76};
77export declare function flatten<T>(array: Array<Array<T>>): Array<T>;
78export declare function unique<T>(array: Array<T>, key?: (item: T) => string | number): Array<T>;
79export {};