@graphql-codegen/gql-tag-operations 1.3.1 → 1.4.0-alpha-1761e9d45.0
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/cjs/index.js +7 -5
- package/esm/index.js +7 -5
- package/package.json +3 -3
- package/typings/index.d.ts +1 -0
package/cjs/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocume
|
|
|
9
9
|
? TType
|
|
10
10
|
: never;
|
|
11
11
|
`.split(`\n`);
|
|
12
|
-
const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleName }, _info) => {
|
|
12
|
+
const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleName, emitLegacyCommonJSImports }, _info) => {
|
|
13
13
|
if (!sourcesWithOperations) {
|
|
14
14
|
return '';
|
|
15
15
|
}
|
|
@@ -20,7 +20,7 @@ const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleN
|
|
|
20
20
|
`\n`,
|
|
21
21
|
...getDocumentRegistryChunk(sourcesWithOperations),
|
|
22
22
|
`\n`,
|
|
23
|
-
...getGqlOverloadChunk(sourcesWithOperations, 'lookup'),
|
|
23
|
+
...getGqlOverloadChunk(sourcesWithOperations, 'lookup', emitLegacyCommonJSImports),
|
|
24
24
|
`\n`,
|
|
25
25
|
`export function gql(source: string): unknown;\n`,
|
|
26
26
|
`export function gql(source: string) {\n`,
|
|
@@ -35,7 +35,7 @@ const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleN
|
|
|
35
35
|
`declare module "${augmentedModuleName}" {`,
|
|
36
36
|
[
|
|
37
37
|
`\n`,
|
|
38
|
-
...getGqlOverloadChunk(sourcesWithOperations, 'augmented'),
|
|
38
|
+
...getGqlOverloadChunk(sourcesWithOperations, 'augmented', emitLegacyCommonJSImports),
|
|
39
39
|
`export function gql(source: string): unknown;\n`,
|
|
40
40
|
`\n`,
|
|
41
41
|
...documentTypePartial,
|
|
@@ -57,7 +57,7 @@ function getDocumentRegistryChunk(sourcesWithOperations = []) {
|
|
|
57
57
|
lines.add(`};\n`);
|
|
58
58
|
return lines;
|
|
59
59
|
}
|
|
60
|
-
function getGqlOverloadChunk(sourcesWithOperations, mode) {
|
|
60
|
+
function getGqlOverloadChunk(sourcesWithOperations, mode, emitLegacyCommonJSImports) {
|
|
61
61
|
const lines = new Set();
|
|
62
62
|
// We intentionally don't use a <T extends keyof typeof documents> generic, because TS
|
|
63
63
|
// would print very long `gql` function signatures (duplicating the source).
|
|
@@ -65,7 +65,9 @@ function getGqlOverloadChunk(sourcesWithOperations, mode) {
|
|
|
65
65
|
const originalString = rest.source.rawSDL;
|
|
66
66
|
const returnType = mode === 'lookup'
|
|
67
67
|
? `(typeof documents)[${JSON.stringify(originalString)}]`
|
|
68
|
-
:
|
|
68
|
+
: emitLegacyCommonJSImports
|
|
69
|
+
? `typeof import('./graphql').${operations[0].initialName}`
|
|
70
|
+
: `typeof import('./graphql.js').${operations[0].initialName}`;
|
|
69
71
|
lines.add(`export function gql(source: ${JSON.stringify(originalString)}): ${returnType};\n`);
|
|
70
72
|
}
|
|
71
73
|
return lines;
|
package/esm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocume
|
|
|
6
6
|
? TType
|
|
7
7
|
: never;
|
|
8
8
|
`.split(`\n`);
|
|
9
|
-
export const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleName }, _info) => {
|
|
9
|
+
export const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleName, emitLegacyCommonJSImports }, _info) => {
|
|
10
10
|
if (!sourcesWithOperations) {
|
|
11
11
|
return '';
|
|
12
12
|
}
|
|
@@ -17,7 +17,7 @@ export const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmented
|
|
|
17
17
|
`\n`,
|
|
18
18
|
...getDocumentRegistryChunk(sourcesWithOperations),
|
|
19
19
|
`\n`,
|
|
20
|
-
...getGqlOverloadChunk(sourcesWithOperations, 'lookup'),
|
|
20
|
+
...getGqlOverloadChunk(sourcesWithOperations, 'lookup', emitLegacyCommonJSImports),
|
|
21
21
|
`\n`,
|
|
22
22
|
`export function gql(source: string): unknown;\n`,
|
|
23
23
|
`export function gql(source: string) {\n`,
|
|
@@ -32,7 +32,7 @@ export const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmented
|
|
|
32
32
|
`declare module "${augmentedModuleName}" {`,
|
|
33
33
|
[
|
|
34
34
|
`\n`,
|
|
35
|
-
...getGqlOverloadChunk(sourcesWithOperations, 'augmented'),
|
|
35
|
+
...getGqlOverloadChunk(sourcesWithOperations, 'augmented', emitLegacyCommonJSImports),
|
|
36
36
|
`export function gql(source: string): unknown;\n`,
|
|
37
37
|
`\n`,
|
|
38
38
|
...documentTypePartial,
|
|
@@ -53,7 +53,7 @@ function getDocumentRegistryChunk(sourcesWithOperations = []) {
|
|
|
53
53
|
lines.add(`};\n`);
|
|
54
54
|
return lines;
|
|
55
55
|
}
|
|
56
|
-
function getGqlOverloadChunk(sourcesWithOperations, mode) {
|
|
56
|
+
function getGqlOverloadChunk(sourcesWithOperations, mode, emitLegacyCommonJSImports) {
|
|
57
57
|
const lines = new Set();
|
|
58
58
|
// We intentionally don't use a <T extends keyof typeof documents> generic, because TS
|
|
59
59
|
// would print very long `gql` function signatures (duplicating the source).
|
|
@@ -61,7 +61,9 @@ function getGqlOverloadChunk(sourcesWithOperations, mode) {
|
|
|
61
61
|
const originalString = rest.source.rawSDL;
|
|
62
62
|
const returnType = mode === 'lookup'
|
|
63
63
|
? `(typeof documents)[${JSON.stringify(originalString)}]`
|
|
64
|
-
:
|
|
64
|
+
: emitLegacyCommonJSImports
|
|
65
|
+
? `typeof import('./graphql').${operations[0].initialName}`
|
|
66
|
+
: `typeof import('./graphql.js').${operations[0].initialName}`;
|
|
65
67
|
lines.add(`export function gql(source: ${JSON.stringify(originalString)}): ${returnType};\n`);
|
|
66
68
|
}
|
|
67
69
|
return lines;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/gql-tag-operations",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-alpha-1761e9d45.0",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating a typed gql tag function",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-tools/utils": "^8.8.0",
|
|
11
|
-
"@graphql-codegen/plugin-helpers": "^2.
|
|
12
|
-
"@graphql-codegen/visitor-plugin-common": "2.
|
|
11
|
+
"@graphql-codegen/plugin-helpers": "^2.6.0-alpha-1761e9d45.0",
|
|
12
|
+
"@graphql-codegen/visitor-plugin-common": "2.12.0-alpha-1761e9d45.0",
|
|
13
13
|
"auto-bind": "~4.0.0",
|
|
14
14
|
"tslib": "~2.4.0"
|
|
15
15
|
},
|