UNPKG

3.63 kBTypeScriptView Raw
1import { NameNode, TypeNode, NamedTypeNode, GraphQLObjectType, GraphQLNamedType, GraphQLSchema, StringValueNode, SelectionSetNode, FieldNode, SelectionNode, FragmentSpreadNode, InlineFragmentNode, GraphQLOutputType } from 'graphql';
2import { ScalarsMap, NormalizedScalarsMap, ParsedScalarsMap } from './types';
3export declare const getConfigValue: <T = any>(value: T, defaultValue: T) => T;
4export declare function quoteIfNeeded(array: string[], joinWith?: string): string;
5export declare function block(array: any): string;
6export declare function wrapWithSingleQuotes(value: string | number | NameNode): string;
7export declare function breakLine(str: string): string;
8export declare function indent(str: string, count?: number): string;
9export declare function indentMultiline(str: string, count?: number): string;
10export interface DeclarationBlockConfig {
11 blockWrapper?: string;
12 blockTransformer?: (block: string) => string;
13 enumNameValueSeparator?: string;
14 ignoreExport?: boolean;
15}
16export declare function transformComment(comment: string | StringValueNode, indentLevel?: number): string;
17export declare class DeclarationBlock {
18 private _config;
19 _decorator: any;
20 _export: boolean;
21 _name: any;
22 _kind: any;
23 _methodName: any;
24 _content: any;
25 _block: any;
26 _nameGenerics: any;
27 _comment: any;
28 _ignoreBlockWrapper: boolean;
29 constructor(_config: DeclarationBlockConfig);
30 withDecorator(decorator: string): DeclarationBlock;
31 export(exp?: boolean): DeclarationBlock;
32 asKind(kind: string): DeclarationBlock;
33 withComment(comment: string | StringValueNode | null): DeclarationBlock;
34 withMethodCall(methodName: string, ignoreBlockWrapper?: boolean): DeclarationBlock;
35 withBlock(block: string): DeclarationBlock;
36 withContent(content: string): DeclarationBlock;
37 withName(name: string | NameNode, generics?: string | null): DeclarationBlock;
38 get string(): string;
39}
40export declare function getBaseTypeNode(typeNode: TypeNode): NamedTypeNode;
41export declare function convertNameParts(str: string, func: (str: string) => string, removeUnderscore?: boolean): string;
42export declare function buildScalars(schema: GraphQLSchema | undefined, scalarsMapping: ScalarsMap, defaultScalarsMapping?: NormalizedScalarsMap, defaultScalarType?: string): ParsedScalarsMap;
43export declare function isRootType(type: GraphQLNamedType, schema: GraphQLSchema): type is GraphQLObjectType;
44export declare function getRootTypeNames(schema: GraphQLSchema): string[];
45export declare function stripMapperTypeInterpolation(identifier: string): string;
46export declare const OMIT_TYPE = "export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;";
47export declare const REQUIRE_FIELDS_TYPE = "export type RequireFields<T, K extends keyof T> = { [X in Exclude<keyof T, K>]?: T[X] } & { [P in K]-?: NonNullable<T[P]> };";
48export declare function mergeSelectionSets(selectionSet1: SelectionSetNode, selectionSet2: SelectionSetNode): void;
49export declare const getFieldNodeNameValue: (node: FieldNode) => string;
50export declare function separateSelectionSet(selections: ReadonlyArray<SelectionNode>): {
51 fields: FieldNode[];
52 spreads: FragmentSpreadNode[];
53 inlines: InlineFragmentNode[];
54};
55export declare function getPossibleTypes(schema: GraphQLSchema, type: GraphQLNamedType): GraphQLObjectType[];
56declare type WrapModifiersOptions = {
57 wrapOptional(type: string): string;
58 wrapArray(type: string): string;
59};
60export declare function wrapTypeWithModifiers(baseType: string, type: GraphQLOutputType, options: WrapModifiersOptions): string;
61export {};