graphql-data-generator 0.1.3 → 0.1.5
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/esm/cli.js +4 -4
- package/esm/init.js +6 -1
- package/esm/proxy.js +1 -1
- package/package.json +6 -3
- package/types/extendedTypes.d.ts +1 -1
- package/types/types.d.ts +2 -2
package/esm/cli.js
CHANGED
|
@@ -14,8 +14,8 @@ const args = parseArgs({
|
|
|
14
14
|
operations: { type: "string", multiple: true },
|
|
15
15
|
scalar: { type: "string", multiple: true },
|
|
16
16
|
outfile: { type: "string" },
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
enums: { type: "boolean" },
|
|
18
|
+
notypenames: { type: "boolean" },
|
|
19
19
|
},
|
|
20
20
|
}).values;
|
|
21
21
|
const findFirst = async (path) => {
|
|
@@ -61,8 +61,8 @@ if (args.scalar) {
|
|
|
61
61
|
}
|
|
62
62
|
try {
|
|
63
63
|
const file = await formatCode(codegen(schema, operations, {
|
|
64
|
-
useEnums: args.
|
|
65
|
-
includeTypenames: args.
|
|
64
|
+
useEnums: args.enums ?? false,
|
|
65
|
+
includeTypenames: !args.notypenames,
|
|
66
66
|
scalars,
|
|
67
67
|
}));
|
|
68
68
|
if (args.outfile)
|
package/esm/init.js
CHANGED
|
@@ -85,7 +85,12 @@ export const init = (schema, queries, mutations, subscriptions, types, inputs, s
|
|
|
85
85
|
if (transforms[name] && "default" in transforms[name]) {
|
|
86
86
|
patches = [transforms[name].default, ...patches];
|
|
87
87
|
}
|
|
88
|
-
const
|
|
88
|
+
const { request: { query: parsedQuery, ...request }, ...raw } = operation(doc.definitions, scalars, query, ...patches);
|
|
89
|
+
const result = toObject({
|
|
90
|
+
request: { ...request },
|
|
91
|
+
...raw,
|
|
92
|
+
});
|
|
93
|
+
result.request.query = parsedQuery;
|
|
89
94
|
return addOperationTransforms(name, options?.finalizeOperation
|
|
90
95
|
? options.finalizeOperation(result)
|
|
91
96
|
: result);
|
package/esm/proxy.js
CHANGED
|
@@ -570,7 +570,7 @@ export const operation = (definitions, scalars, query, ...patches) => {
|
|
|
570
570
|
throw new Error("Expected operation to be named");
|
|
571
571
|
const { variables, data, error, errors, ...extra } = _proxy([...definitions, ...document.definitions], scalars, operation.name.value, patches);
|
|
572
572
|
const mock = {
|
|
573
|
-
request: { query },
|
|
573
|
+
request: { query: document },
|
|
574
574
|
result: {},
|
|
575
575
|
...extra,
|
|
576
576
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql-data-generator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/vocesgraphql-data-generator/.git"
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/voces/graphql-data-generator/issues"
|
|
11
11
|
},
|
|
12
|
+
"main": "./esm/index.js",
|
|
12
13
|
"module": "./esm/index.js",
|
|
13
14
|
"types": "./types/index.d.ts",
|
|
14
15
|
"exports": {
|
|
@@ -24,11 +25,13 @@
|
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
27
|
"fast-glob": "*",
|
|
27
|
-
"graphql": "*",
|
|
28
28
|
"@deno/shim-deno": "~0.18.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.9.0"
|
|
32
32
|
},
|
|
33
|
-
"_generatedBy": "dnt@dev"
|
|
33
|
+
"_generatedBy": "dnt@dev",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"graphql": "*"
|
|
36
|
+
}
|
|
34
37
|
}
|
package/types/extendedTypes.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ type MapOperationsToBuilders<T, Transforms, Extra> = {
|
|
|
40
40
|
data: infer U;
|
|
41
41
|
} ? U extends Record<string, unknown> ? U : Record<string, unknown> : Record<string, unknown>, T[K] extends {
|
|
42
42
|
variables: infer U;
|
|
43
|
-
} ? U :
|
|
43
|
+
} ? U : never, K extends keyof Transforms ? Transforms[K] : ContravariantEmpty, Extra>;
|
|
44
44
|
};
|
|
45
45
|
type ResolveOperationConflicts<T, Name extends string, A, B, C, D> = Omit<T, keyof A | keyof B | keyof C | keyof D> & PrefixKeys<Pick<T, keyof T & (keyof A | keyof B | keyof C | keyof D)>, Name>;
|
|
46
46
|
type ResolveConflicts<Queries, Mutations, Subscriptions, Types, Inputs> = ResolveOperationConflicts<Queries, "queries", Mutations, Subscriptions, Types, Inputs> & ResolveOperationConflicts<Mutations, "mutations", Queries, Subscriptions, Types, Inputs> & ResolveOperationConflicts<Subscriptions, "subscriptions", Queries, Mutations, Types, Inputs>;
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraphQLError } from "graphql";
|
|
1
|
+
import type { DocumentNode, GraphQLError } from "graphql";
|
|
2
2
|
export type ContravariantEmpty = Record<string, never>;
|
|
3
3
|
export type CovariantEmpty = object;
|
|
4
4
|
type ArrayPatch<T> = Patch<T>[] | ({
|
|
@@ -19,7 +19,7 @@ export type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extend
|
|
|
19
19
|
} : T;
|
|
20
20
|
export type OperationMock<Data extends Record<string, unknown> = Record<string, unknown>, Variables = Record<string, unknown> | never> = {
|
|
21
21
|
request: {
|
|
22
|
-
query:
|
|
22
|
+
query: DocumentNode;
|
|
23
23
|
variables?: Variables;
|
|
24
24
|
};
|
|
25
25
|
result: {
|