@constructive-io/graphql-codegen 2.17.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +161 -0
- package/codegen.d.ts +13 -0
- package/codegen.js +267 -0
- package/esm/codegen.js +227 -0
- package/esm/gql.js +721 -0
- package/esm/index.js +3 -0
- package/esm/options.js +21 -0
- package/gql.d.ts +163 -0
- package/gql.js +774 -0
- package/index.d.ts +3 -0
- package/index.js +19 -0
- package/options.d.ts +37 -0
- package/options.js +25 -0
- package/package.json +62 -0
package/esm/index.js
ADDED
package/esm/options.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const defaultGraphQLCodegenOptions = {
|
|
2
|
+
input: { schema: '', endpoint: '', headers: {} },
|
|
3
|
+
output: {
|
|
4
|
+
root: 'graphql/codegen/dist',
|
|
5
|
+
typesFile: 'types/generated.ts',
|
|
6
|
+
operationsDir: 'operations',
|
|
7
|
+
sdkFile: 'sdk.ts',
|
|
8
|
+
reactQueryFile: 'react-query.ts'
|
|
9
|
+
},
|
|
10
|
+
documents: { format: 'gql', convention: 'dashed', allowQueries: [], excludeQueries: [], excludePatterns: [] },
|
|
11
|
+
features: { emitTypes: true, emitOperations: true, emitSdk: true, emitReactQuery: true },
|
|
12
|
+
reactQuery: { fetcher: 'graphql-request', legacyMode: false, exposeDocument: false, addInfiniteQuery: false }
|
|
13
|
+
};
|
|
14
|
+
export function mergeGraphQLCodegenOptions(base, overrides) {
|
|
15
|
+
return {
|
|
16
|
+
input: { ...(base.input || {}), ...(overrides.input || {}) },
|
|
17
|
+
output: { ...(base.output || {}), ...(overrides.output || {}) },
|
|
18
|
+
documents: { ...(base.documents || {}), ...(overrides.documents || {}) },
|
|
19
|
+
features: { ...(base.features || {}), ...(overrides.features || {}) }
|
|
20
|
+
};
|
|
21
|
+
}
|
package/gql.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { ArgumentNode, DocumentNode, FieldNode, VariableDefinitionNode } from 'graphql';
|
|
2
|
+
interface CreateGqlMutationArgs {
|
|
3
|
+
operationName: string;
|
|
4
|
+
mutationName: string;
|
|
5
|
+
selectArgs: ArgumentNode[];
|
|
6
|
+
selections: FieldNode[];
|
|
7
|
+
variableDefinitions: VariableDefinitionNode[];
|
|
8
|
+
modelName?: string;
|
|
9
|
+
useModel?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const createGqlMutation: ({ operationName, mutationName, selectArgs, variableDefinitions, modelName, selections, useModel, }: CreateGqlMutationArgs) => DocumentNode;
|
|
12
|
+
export interface GetManyArgs {
|
|
13
|
+
operationName: string;
|
|
14
|
+
query: any;
|
|
15
|
+
fields: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface GetManyResult {
|
|
18
|
+
name: string;
|
|
19
|
+
ast: DocumentNode;
|
|
20
|
+
}
|
|
21
|
+
export declare const getMany: ({ operationName, query, fields, }: GetManyArgs) => GetManyResult;
|
|
22
|
+
export interface GetManyPaginatedEdgesArgs {
|
|
23
|
+
operationName: string;
|
|
24
|
+
query: GqlField;
|
|
25
|
+
fields: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface GetManyPaginatedEdgesResult {
|
|
28
|
+
name: string;
|
|
29
|
+
ast: DocumentNode;
|
|
30
|
+
}
|
|
31
|
+
export declare const getManyPaginatedEdges: ({ operationName, query, fields, }: GetManyPaginatedEdgesArgs) => GetManyPaginatedEdgesResult;
|
|
32
|
+
export interface GetManyPaginatedNodesArgs {
|
|
33
|
+
operationName: string;
|
|
34
|
+
query: GqlField;
|
|
35
|
+
fields: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface GetManyPaginatedNodesResult {
|
|
38
|
+
name: string;
|
|
39
|
+
ast: DocumentNode;
|
|
40
|
+
}
|
|
41
|
+
export declare const getManyPaginatedNodes: ({ operationName, query, fields, }: GetManyPaginatedNodesArgs) => GetManyPaginatedNodesResult;
|
|
42
|
+
export interface GetOrderByEnumsArgs {
|
|
43
|
+
operationName: string;
|
|
44
|
+
query: {
|
|
45
|
+
model: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface GetOrderByEnumsResult {
|
|
49
|
+
name: string;
|
|
50
|
+
ast: DocumentNode;
|
|
51
|
+
}
|
|
52
|
+
export declare const getOrderByEnums: ({ operationName, query, }: GetOrderByEnumsArgs) => GetOrderByEnumsResult;
|
|
53
|
+
export interface GetFragmentArgs {
|
|
54
|
+
operationName: string;
|
|
55
|
+
query: GqlField;
|
|
56
|
+
}
|
|
57
|
+
export interface GetFragmentResult {
|
|
58
|
+
name: string;
|
|
59
|
+
ast: DocumentNode;
|
|
60
|
+
}
|
|
61
|
+
export declare const getFragment: ({ operationName, query, }: GetFragmentArgs) => GetFragmentResult;
|
|
62
|
+
export interface FieldProperty {
|
|
63
|
+
name: string;
|
|
64
|
+
type: string;
|
|
65
|
+
isNotNull?: boolean;
|
|
66
|
+
isArray?: boolean;
|
|
67
|
+
isArrayNotNull?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface GetOneArgs {
|
|
70
|
+
operationName: string;
|
|
71
|
+
query: GqlField;
|
|
72
|
+
fields: string[];
|
|
73
|
+
}
|
|
74
|
+
export interface GetOneResult {
|
|
75
|
+
name: string;
|
|
76
|
+
ast: DocumentNode;
|
|
77
|
+
}
|
|
78
|
+
export declare const getOne: ({ operationName, query, fields, }: GetOneArgs) => GetOneResult;
|
|
79
|
+
export interface CreateOneArgs {
|
|
80
|
+
operationName: string;
|
|
81
|
+
mutation: MutationSpec;
|
|
82
|
+
}
|
|
83
|
+
export interface CreateOneResult {
|
|
84
|
+
name: string;
|
|
85
|
+
ast: DocumentNode;
|
|
86
|
+
}
|
|
87
|
+
export declare const createOne: ({ operationName, mutation, }: CreateOneArgs) => CreateOneResult | undefined;
|
|
88
|
+
interface MutationOutput {
|
|
89
|
+
name: string;
|
|
90
|
+
type: {
|
|
91
|
+
kind: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export interface MutationSpec {
|
|
95
|
+
model: string;
|
|
96
|
+
properties: {
|
|
97
|
+
input?: {
|
|
98
|
+
properties?: Record<string, any>;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
outputs?: MutationOutput[];
|
|
102
|
+
}
|
|
103
|
+
export interface PatchOneArgs {
|
|
104
|
+
operationName: string;
|
|
105
|
+
mutation: MutationSpec;
|
|
106
|
+
}
|
|
107
|
+
export interface PatchOneResult {
|
|
108
|
+
name: string;
|
|
109
|
+
ast: DocumentNode;
|
|
110
|
+
}
|
|
111
|
+
export declare const patchOne: ({ operationName, mutation, }: PatchOneArgs) => PatchOneResult | undefined;
|
|
112
|
+
export interface DeleteOneArgs {
|
|
113
|
+
operationName: string;
|
|
114
|
+
mutation: MutationSpec;
|
|
115
|
+
}
|
|
116
|
+
export interface DeleteOneResult {
|
|
117
|
+
name: string;
|
|
118
|
+
ast: DocumentNode;
|
|
119
|
+
}
|
|
120
|
+
export declare const deleteOne: ({ operationName, mutation, }: DeleteOneArgs) => DeleteOneResult | undefined;
|
|
121
|
+
export interface CreateMutationArgs {
|
|
122
|
+
operationName: string;
|
|
123
|
+
mutation: MutationSpec;
|
|
124
|
+
}
|
|
125
|
+
export interface CreateMutationResult {
|
|
126
|
+
name: string;
|
|
127
|
+
ast: DocumentNode;
|
|
128
|
+
}
|
|
129
|
+
export declare const createMutation: ({ operationName, mutation, }: CreateMutationArgs) => CreateMutationResult | undefined;
|
|
130
|
+
type QType = 'mutation' | 'getOne' | 'getMany';
|
|
131
|
+
type MutationType = 'create' | 'patch' | 'delete' | string;
|
|
132
|
+
interface FlatField {
|
|
133
|
+
name: string;
|
|
134
|
+
selection: string[];
|
|
135
|
+
}
|
|
136
|
+
interface GqlField {
|
|
137
|
+
qtype: QType;
|
|
138
|
+
mutationType?: MutationType;
|
|
139
|
+
model?: string;
|
|
140
|
+
properties?: Record<string, Omit<FieldProperty, 'name'>>;
|
|
141
|
+
outputs?: {
|
|
142
|
+
name: string;
|
|
143
|
+
type: {
|
|
144
|
+
kind: string;
|
|
145
|
+
};
|
|
146
|
+
}[];
|
|
147
|
+
selection?: QueryField[];
|
|
148
|
+
}
|
|
149
|
+
type QueryField = string | FlatField;
|
|
150
|
+
export interface GqlMap {
|
|
151
|
+
[operationName: string]: GqlField;
|
|
152
|
+
}
|
|
153
|
+
interface AstMapEntry {
|
|
154
|
+
name: string;
|
|
155
|
+
ast: DocumentNode;
|
|
156
|
+
}
|
|
157
|
+
interface AstMap {
|
|
158
|
+
[key: string]: AstMapEntry;
|
|
159
|
+
}
|
|
160
|
+
export declare const generate: (gql: GqlMap) => AstMap;
|
|
161
|
+
export declare const generateGranular: (gql: GqlMap, model: string, fields: string[]) => AstMap;
|
|
162
|
+
export declare function getSelections(query: GqlField, fields?: string[]): FieldNode[];
|
|
163
|
+
export {};
|