UNPKG

4.25 kBTypeScriptView Raw
1import { NameNode, TypeNode, NamedTypeNode, GraphQLObjectType, GraphQLNamedType, GraphQLSchema, StringValueNode, SelectionSetNode, FieldNode, SelectionNode, FragmentSpreadNode, InlineFragmentNode, GraphQLOutputType } from 'graphql';
2import { ScalarsMap, NormalizedScalarsMap, ParsedScalarsMap } from './types';
3import { RawConfig } from './base-visitor';
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[];
56 spreads: FragmentSpreadNode[];
57 inlines: InlineFragmentNode[];
58};
59export declare function getPossibleTypes(schema: GraphQLSchema, type: GraphQLNamedType): GraphQLObjectType[];
60export declare function hasConditionalDirectives(field: FieldNode): boolean;
61declare type WrapModifiersOptions = {
62 wrapOptional(type: string): string;
63 wrapArray(type: string): string;
64};
65export declare function wrapTypeWithModifiers(baseType: string, type: GraphQLOutputType | GraphQLNamedType, options: WrapModifiersOptions): string;
66export declare function removeDescription<T extends {
67 description?: StringValueNode;
68}>(nodes: readonly T[]): (T & {
69 description: any;
70})[];
71export declare function wrapTypeNodeWithModifiers(baseType: string, typeNode: TypeNode): string;
72export {};