UNPKG

2.97 kBTypeScriptView Raw
1import { ASTNode, FragmentDefinitionNode } from 'graphql';
2import { ParsedMapper } from './mappers';
3/**
4 * Scalars map or a string, a map between the GraphQL scalar name and the identifier that should be used
5 */
6export declare type ScalarsMap = string | {
7 [name: string]: string;
8};
9/**
10 * A normalized map between GraphQL scalar name and the identifier name
11 */
12export declare type NormalizedScalarsMap = {
13 [name: string]: string;
14};
15/**
16 * Parsed scalars map - a mapping between GraphQL scalar name and the parsed mapper object,
17 * including all required information for generting code for that mapping.
18 */
19export declare type ParsedScalarsMap = {
20 [name: string]: ParsedMapper;
21};
22/**
23 * A raw configuration for enumValues map - can be represented with a single string value for a file path,
24 * a map between enum name and a file path, or a map between enum name and an object with explicit enum values.
25 */
26export declare type EnumValuesMap<AdditionalProps = {}> = string | {
27 [enumName: string]: string | ({
28 [key: string]: string | number;
29 } & AdditionalProps);
30};
31export declare type ParsedEnumValuesMap = {
32 [enumName: string]: {
33 mappedValues?: {
34 [valueName: string]: string | number;
35 };
36 typeIdentifier: string;
37 sourceIdentifier?: string;
38 sourceFile?: string;
39 importIdentifier?: string;
40 isDefault?: boolean;
41 };
42};
43export declare type ConvertNameFn<T = {}> = ConvertFn<T>;
44export declare type GetFragmentSuffixFn = (node: FragmentDefinitionNode | string) => string;
45export interface ConvertOptions {
46 prefix?: string;
47 suffix?: string;
48 transformUnderscore?: boolean;
49}
50export declare type ConvertFn<T = {}> = (node: ASTNode | string, options?: ConvertOptions & T) => string;
51export declare type NamingConventionFn = (str: string) => string;
52export declare type NamingConventionResolvePath = string;
53export declare type NamingConvention = string | NamingConventionFn | NamingConventionMap;
54/**
55 * @additionalProperties false
56 */
57export interface NamingConventionMap {
58 enumValues?: 'keep' | NamingConventionResolvePath | NamingConventionFn;
59 typeNames?: 'keep' | NamingConventionResolvePath | NamingConventionFn;
60 transformUnderscore?: boolean;
61}
62export declare type LoadedFragment<AdditionalFields = {}> = {
63 name: string;
64 onType: string;
65 node: FragmentDefinitionNode;
66 isExternal: boolean;
67 importFrom?: string | null;
68} & AdditionalFields;
69export declare type DeclarationKind = 'type' | 'interface' | 'class' | 'abstract class';
70export interface DeclarationKindConfig {
71 scalar?: DeclarationKind;
72 input?: DeclarationKind;
73 type?: DeclarationKind;
74 interface?: DeclarationKind;
75 arguments?: DeclarationKind;
76}
77export interface AvoidOptionalsConfig {
78 field?: boolean;
79 object?: boolean;
80 inputValue?: boolean;
81}
82export interface ParsedImport {
83 moduleName: string | null;
84 propName: string;
85}