UNPKG

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