@constructive-io/graphql-codegen 2.17.29 → 2.17.31
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/README.md +97 -0
- package/codegen.js +35 -9
- package/esm/codegen.js +35 -9
- package/esm/gql.js +333 -159
- package/esm/options.js +8 -2
- package/gql.d.ts +37 -6
- package/gql.js +333 -159
- package/options.d.ts +10 -0
- package/options.js +8 -2
- package/package.json +4 -4
package/esm/options.js
CHANGED
|
@@ -9,13 +9,19 @@ export const defaultGraphQLCodegenOptions = {
|
|
|
9
9
|
},
|
|
10
10
|
documents: { format: 'gql', convention: 'dashed', allowQueries: [], excludeQueries: [], excludePatterns: [] },
|
|
11
11
|
features: { emitTypes: true, emitOperations: true, emitSdk: true, emitReactQuery: true },
|
|
12
|
-
reactQuery: { fetcher: 'graphql-request', legacyMode: false, exposeDocument: false, addInfiniteQuery: false }
|
|
12
|
+
reactQuery: { fetcher: 'graphql-request', legacyMode: false, exposeDocument: false, addInfiniteQuery: false, reactQueryVersion: 5 },
|
|
13
|
+
selection: { defaultMutationModelFields: ['id'], modelFields: {}, mutationInputMode: 'patchCollapsed', connectionStyle: 'edges', forceModelOutput: true },
|
|
14
|
+
scalars: {},
|
|
15
|
+
typeNameOverrides: {}
|
|
13
16
|
};
|
|
14
17
|
export function mergeGraphQLCodegenOptions(base, overrides) {
|
|
15
18
|
return {
|
|
16
19
|
input: { ...(base.input || {}), ...(overrides.input || {}) },
|
|
17
20
|
output: { ...(base.output || {}), ...(overrides.output || {}) },
|
|
18
21
|
documents: { ...(base.documents || {}), ...(overrides.documents || {}) },
|
|
19
|
-
features: { ...(base.features || {}), ...(overrides.features || {}) }
|
|
22
|
+
features: { ...(base.features || {}), ...(overrides.features || {}) },
|
|
23
|
+
selection: { ...(base.selection || {}), ...(overrides.selection || {}) },
|
|
24
|
+
scalars: { ...(base.scalars || {}), ...(overrides.scalars || {}) },
|
|
25
|
+
typeNameOverrides: { ...(base.typeNameOverrides || {}), ...(overrides.typeNameOverrides || {}) }
|
|
20
26
|
};
|
|
21
27
|
}
|
package/gql.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ArgumentNode, DocumentNode, FieldNode, VariableDefinitionNode } from 'graphql';
|
|
2
|
+
type TypeIndex = {
|
|
3
|
+
byName: Record<string, any>;
|
|
4
|
+
getInputFieldType: (typeName: string, fieldName: string) => any;
|
|
5
|
+
};
|
|
2
6
|
interface CreateGqlMutationArgs {
|
|
3
7
|
operationName: string;
|
|
4
8
|
mutationName: string;
|
|
@@ -75,16 +79,23 @@ export interface GetOneResult {
|
|
|
75
79
|
name: string;
|
|
76
80
|
ast: DocumentNode;
|
|
77
81
|
}
|
|
78
|
-
export declare const getOne: ({ operationName, query, fields, }: GetOneArgs) => GetOneResult;
|
|
82
|
+
export declare const getOne: ({ operationName, query, fields, }: GetOneArgs, typeNameOverrides?: Record<string, string>) => GetOneResult;
|
|
79
83
|
export interface CreateOneArgs {
|
|
80
84
|
operationName: string;
|
|
81
85
|
mutation: MutationSpec;
|
|
86
|
+
selection?: {
|
|
87
|
+
defaultMutationModelFields?: string[];
|
|
88
|
+
modelFields?: Record<string, string[]>;
|
|
89
|
+
mutationInputMode?: 'expanded' | 'model' | 'raw' | 'patchCollapsed';
|
|
90
|
+
connectionStyle?: 'nodes' | 'edges';
|
|
91
|
+
forceModelOutput?: boolean;
|
|
92
|
+
};
|
|
82
93
|
}
|
|
83
94
|
export interface CreateOneResult {
|
|
84
95
|
name: string;
|
|
85
96
|
ast: DocumentNode;
|
|
86
97
|
}
|
|
87
|
-
export declare const createOne: ({ operationName, mutation, }: CreateOneArgs) => CreateOneResult | undefined;
|
|
98
|
+
export declare const createOne: ({ operationName, mutation, selection, }: CreateOneArgs, typeNameOverrides?: Record<string, string>, typeIndex?: TypeIndex) => CreateOneResult | undefined;
|
|
88
99
|
interface MutationOutput {
|
|
89
100
|
name: string;
|
|
90
101
|
type: {
|
|
@@ -103,12 +114,19 @@ export interface MutationSpec {
|
|
|
103
114
|
export interface PatchOneArgs {
|
|
104
115
|
operationName: string;
|
|
105
116
|
mutation: MutationSpec;
|
|
117
|
+
selection?: {
|
|
118
|
+
defaultMutationModelFields?: string[];
|
|
119
|
+
modelFields?: Record<string, string[]>;
|
|
120
|
+
mutationInputMode?: 'expanded' | 'model' | 'raw' | 'patchCollapsed';
|
|
121
|
+
connectionStyle?: 'nodes' | 'edges';
|
|
122
|
+
forceModelOutput?: boolean;
|
|
123
|
+
};
|
|
106
124
|
}
|
|
107
125
|
export interface PatchOneResult {
|
|
108
126
|
name: string;
|
|
109
127
|
ast: DocumentNode;
|
|
110
128
|
}
|
|
111
|
-
export declare const patchOne: ({ operationName, mutation, }: PatchOneArgs) => PatchOneResult | undefined;
|
|
129
|
+
export declare const patchOne: ({ operationName, mutation, selection, }: PatchOneArgs, typeNameOverrides?: Record<string, string>, typeIndex?: TypeIndex) => PatchOneResult | undefined;
|
|
112
130
|
export interface DeleteOneArgs {
|
|
113
131
|
operationName: string;
|
|
114
132
|
mutation: MutationSpec;
|
|
@@ -117,16 +135,23 @@ export interface DeleteOneResult {
|
|
|
117
135
|
name: string;
|
|
118
136
|
ast: DocumentNode;
|
|
119
137
|
}
|
|
120
|
-
export declare const deleteOne: ({ operationName, mutation, }: DeleteOneArgs) => DeleteOneResult | undefined;
|
|
138
|
+
export declare const deleteOne: ({ operationName, mutation, }: DeleteOneArgs, typeNameOverrides?: Record<string, string>, typeIndex?: TypeIndex) => DeleteOneResult | undefined;
|
|
121
139
|
export interface CreateMutationArgs {
|
|
122
140
|
operationName: string;
|
|
123
141
|
mutation: MutationSpec;
|
|
142
|
+
selection?: {
|
|
143
|
+
defaultMutationModelFields?: string[];
|
|
144
|
+
modelFields?: Record<string, string[]>;
|
|
145
|
+
mutationInputMode?: 'expanded' | 'model' | 'raw' | 'patchCollapsed';
|
|
146
|
+
connectionStyle?: 'nodes' | 'edges';
|
|
147
|
+
forceModelOutput?: boolean;
|
|
148
|
+
};
|
|
124
149
|
}
|
|
125
150
|
export interface CreateMutationResult {
|
|
126
151
|
name: string;
|
|
127
152
|
ast: DocumentNode;
|
|
128
153
|
}
|
|
129
|
-
export declare const createMutation: ({ operationName, mutation, }: CreateMutationArgs) => CreateMutationResult | undefined;
|
|
154
|
+
export declare const createMutation: ({ operationName, mutation, selection, }: CreateMutationArgs, typeNameOverrides?: Record<string, string>, typeIndex?: TypeIndex) => CreateMutationResult | undefined;
|
|
130
155
|
type QType = 'mutation' | 'getOne' | 'getMany';
|
|
131
156
|
type MutationType = 'create' | 'patch' | 'delete' | string;
|
|
132
157
|
interface FlatField {
|
|
@@ -157,7 +182,13 @@ interface AstMapEntry {
|
|
|
157
182
|
interface AstMap {
|
|
158
183
|
[key: string]: AstMapEntry;
|
|
159
184
|
}
|
|
160
|
-
export declare const generate: (gql: GqlMap
|
|
185
|
+
export declare const generate: (gql: GqlMap, selection?: {
|
|
186
|
+
defaultMutationModelFields?: string[];
|
|
187
|
+
modelFields?: Record<string, string[]>;
|
|
188
|
+
mutationInputMode?: "expanded" | "model" | "raw" | "patchCollapsed";
|
|
189
|
+
connectionStyle?: "nodes" | "edges";
|
|
190
|
+
forceModelOutput?: boolean;
|
|
191
|
+
}, typeNameOverrides?: Record<string, string>, typeIndex?: TypeIndex) => AstMap;
|
|
161
192
|
export declare const generateGranular: (gql: GqlMap, model: string, fields: string[]) => AstMap;
|
|
162
193
|
export declare function getSelections(query: GqlField, fields?: string[]): FieldNode[];
|
|
163
194
|
export {};
|