@graphitation/graphql-codegen-supermassive-typed-document-node-plugin 0.3.3 → 0.4.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/.eslintcache +1 -1
- package/CHANGELOG.md +19 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/visitor.d.ts +10 -2
- package/lib/visitor.d.ts.map +1 -1
- package/lib/visitor.js +23 -5
- package/lib/visitor.mjs +23 -5
- package/package.json +2 -2
package/.eslintcache
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"/mnt/vss/_work/1/s/packages/graphql-codegen-supermassive-typed-document-node-plugin/src/index.ts":"1","/mnt/vss/_work/1/s/packages/graphql-codegen-supermassive-typed-document-node-plugin/src/visitor.ts":"2"},{"size":
|
|
1
|
+
[{"/mnt/vss/_work/1/s/packages/graphql-codegen-supermassive-typed-document-node-plugin/src/index.ts":"1","/mnt/vss/_work/1/s/packages/graphql-codegen-supermassive-typed-document-node-plugin/src/visitor.ts":"2"},{"size":2457,"mtime":1680603722473,"results":"3","hashOfConfig":"4"},{"size":5731,"mtime":1680603722473,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"12nwo86",{"filePath":"8","messages":"9","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/mnt/vss/_work/1/s/packages/graphql-codegen-supermassive-typed-document-node-plugin/src/index.ts",[],"/mnt/vss/_work/1/s/packages/graphql-codegen-supermassive-typed-document-node-plugin/src/visitor.ts",[]]
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - @graphitation/graphql-codegen-supermassive-typed-document-node-plugin
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue,
|
|
3
|
+
This log was last generated on Tue, 04 Apr 2023 10:29:00 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.4.0
|
|
8
|
+
|
|
9
|
+
Tue, 04 Apr 2023 10:29:00 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Support conditional annotations in `graphql-codegen-supermassive-typed-document-node-plugin` (vladimir.razuvaev@gmail.com)
|
|
14
|
+
- Bump @graphitation/supermassive to v2.4.0
|
|
15
|
+
|
|
16
|
+
## 0.3.4
|
|
17
|
+
|
|
18
|
+
Thu, 30 Mar 2023 08:30:21 GMT
|
|
19
|
+
|
|
20
|
+
### Patches
|
|
21
|
+
|
|
22
|
+
- Bump @graphitation/supermassive to v2.3.0
|
|
23
|
+
|
|
7
24
|
## 0.3.3
|
|
8
25
|
|
|
9
|
-
Tue, 28 Mar 2023 10:27:
|
|
26
|
+
Tue, 28 Mar 2023 10:27:19 GMT
|
|
10
27
|
|
|
11
28
|
### Patches
|
|
12
29
|
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,gBAAgB,EAChB,cAAc,EACf,MAAM,iCAAiC,CAAC;AAYzC,OAAO,EAEL,6BAA6B,EAE9B,MAAM,wCAAwC,CAAC;AAGhD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,gBAAgB,EAChB,cAAc,EACf,MAAM,iCAAiC,CAAC;AAYzC,OAAO,EAEL,6BAA6B,EAE9B,MAAM,wCAAwC,CAAC;AAGhD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,6BAA6B,CAsChE,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,gBAAgB,CAAC,6BAA6B,CAiBpE,CAAC"}
|
package/lib/visitor.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { Types } from "@graphql-codegen/plugin-helpers";
|
|
2
2
|
import { LoadedFragment, ClientSideBaseVisitor, ClientSideBasePluginConfig, RawClientSideBasePluginConfig } from "@graphql-codegen/visitor-plugin-common";
|
|
3
3
|
import { GraphQLSchema, FragmentDefinitionNode, OperationDefinitionNode } from "graphql";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
declare type RawClientSidePluginConfig = RawClientSideBasePluginConfig & {
|
|
5
|
+
supermassiveDocumentNodeConditional?: string;
|
|
6
|
+
};
|
|
7
|
+
declare type ClientSidePluginConfig = ClientSideBasePluginConfig & {
|
|
8
|
+
supermassiveDocumentNodeConditional?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class TypeScriptDocumentNodesVisitor extends ClientSideBaseVisitor<RawClientSidePluginConfig, ClientSidePluginConfig> {
|
|
11
|
+
constructor(schema: GraphQLSchema, fragments: LoadedFragment[], rawConfig: RawClientSidePluginConfig, documents: Types.DocumentFile[]);
|
|
6
12
|
protected _gql(node: FragmentDefinitionNode | OperationDefinitionNode): string;
|
|
13
|
+
protected _render(node: FragmentDefinitionNode | OperationDefinitionNode, annotate?: boolean): string;
|
|
7
14
|
private _transformDocumentNodeToSupermassive;
|
|
8
15
|
protected getDocumentNodeSignature(resultType: string, variablesTypes: string, node: FragmentDefinitionNode | OperationDefinitionNode): string;
|
|
9
16
|
}
|
|
17
|
+
export {};
|
|
10
18
|
//# sourceMappingURL=visitor.d.ts.map
|
package/lib/visitor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../src/visitor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAE1B,6BAA6B,EAC9B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,aAAa,EACb,sBAAsB,EAItB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAQjB,qBAAa,8BAA+B,SAAQ,qBAAqB,CACvE,
|
|
1
|
+
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../src/visitor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAE1B,6BAA6B,EAC9B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,aAAa,EACb,sBAAsB,EAItB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAQjB,aAAK,yBAAyB,GAAG,6BAA6B,GAAG;IAC/D,mCAAmC,CAAC,EAAE,MAAM,CAAC;CAC9C,CAAC;AACF,aAAK,sBAAsB,GAAG,0BAA0B,GAAG;IACzD,mCAAmC,CAAC,EAAE,MAAM,CAAC;CAC9C,CAAC;AAEF,qBAAa,8BAA+B,SAAQ,qBAAqB,CACvE,yBAAyB,EACzB,sBAAsB,CACvB;gBAEG,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,cAAc,EAAE,EAC3B,SAAS,EAAE,yBAAyB,EACpC,SAAS,EAAE,KAAK,CAAC,YAAY,EAAE;IAkCjC,SAAS,CAAC,IAAI,CACZ,IAAI,EAAE,sBAAsB,GAAG,uBAAuB,GACrD,MAAM;IAST,SAAS,CAAC,OAAO,CACf,IAAI,EAAE,sBAAsB,GAAG,uBAAuB,EACtD,QAAQ,UAAQ,GACf,MAAM;IAmET,OAAO,CAAC,oCAAoC;IAY5C,SAAS,CAAC,wBAAwB,CAChC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,sBAAsB,GAAG,uBAAuB;CAYzD"}
|
package/lib/visitor.js
CHANGED
|
@@ -63,7 +63,9 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
|
|
|
63
63
|
documentMode: import_visitor_plugin_common.DocumentMode.documentNodeImportFragments,
|
|
64
64
|
documentNodeImport: "@graphql-typed-document-node/core#TypedDocumentNode"
|
|
65
65
|
}, rawConfig),
|
|
66
|
-
{
|
|
66
|
+
{
|
|
67
|
+
supermassiveDocumentNodeConditional: rawConfig.supermassiveDocumentNodeConditional
|
|
68
|
+
},
|
|
67
69
|
documents
|
|
68
70
|
);
|
|
69
71
|
(0, import_auto_bind.default)(this);
|
|
@@ -80,6 +82,16 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
_gql(node) {
|
|
85
|
+
if (this.config.supermassiveDocumentNodeConditional) {
|
|
86
|
+
const supermassive = this._render(node, true);
|
|
87
|
+
const standard = this._render(node, false);
|
|
88
|
+
return `(${this.config.supermassiveDocumentNodeConditional}
|
|
89
|
+
? ${supermassive}
|
|
90
|
+
: ${standard})`;
|
|
91
|
+
}
|
|
92
|
+
return this._render(node, true);
|
|
93
|
+
}
|
|
94
|
+
_render(node, annotate = false) {
|
|
83
95
|
const supermassiveNode = (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
|
|
84
96
|
kind: import_graphql.Kind.DOCUMENT,
|
|
85
97
|
definitions: [node]
|
|
@@ -93,7 +105,10 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
|
|
|
93
105
|
if (this.config.optimizeDocumentNode) {
|
|
94
106
|
gqlObj = (0, import_optimize.optimizeDocumentNode)(gqlObj);
|
|
95
107
|
}
|
|
96
|
-
|
|
108
|
+
if (annotate) {
|
|
109
|
+
gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);
|
|
110
|
+
}
|
|
111
|
+
return JSON.stringify(gqlObj);
|
|
97
112
|
} else if (this.config.documentMode === import_visitor_plugin_common.DocumentMode.documentNodeImportFragments) {
|
|
98
113
|
let gqlObj = (0, import_graphql_tag.default)([doc]);
|
|
99
114
|
if (this.config.optimizeDocumentNode) {
|
|
@@ -103,17 +118,20 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
|
|
|
103
118
|
const definitions = [
|
|
104
119
|
...gqlObj.definitions.map(
|
|
105
120
|
(t) => JSON.stringify(
|
|
106
|
-
(0, import_supermassive.addTypesToRequestDocument)(this._schema, {
|
|
121
|
+
annotate ? (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
|
|
107
122
|
kind: import_graphql.Kind.DOCUMENT,
|
|
108
123
|
definitions: [t]
|
|
109
|
-
}).definitions[0]
|
|
124
|
+
}).definitions[0] : t
|
|
110
125
|
)
|
|
111
126
|
),
|
|
112
127
|
...fragments.map((name) => `...${name}.definitions`)
|
|
113
128
|
].join();
|
|
114
129
|
return `{"kind":"${import_graphql.Kind.DOCUMENT}","definitions":[${definitions}]}`;
|
|
115
130
|
}
|
|
116
|
-
|
|
131
|
+
if (annotate) {
|
|
132
|
+
gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);
|
|
133
|
+
}
|
|
134
|
+
return JSON.stringify(gqlObj);
|
|
117
135
|
} else if (this.config.documentMode === import_visitor_plugin_common.DocumentMode.string) {
|
|
118
136
|
return "`" + doc + "`";
|
|
119
137
|
}
|
package/lib/visitor.mjs
CHANGED
|
@@ -42,7 +42,9 @@ var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
|
|
|
42
42
|
documentMode: DocumentMode.documentNodeImportFragments,
|
|
43
43
|
documentNodeImport: "@graphql-typed-document-node/core#TypedDocumentNode"
|
|
44
44
|
}, rawConfig),
|
|
45
|
-
{
|
|
45
|
+
{
|
|
46
|
+
supermassiveDocumentNodeConditional: rawConfig.supermassiveDocumentNodeConditional
|
|
47
|
+
},
|
|
46
48
|
documents
|
|
47
49
|
);
|
|
48
50
|
autoBind(this);
|
|
@@ -59,6 +61,16 @@ var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
|
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
_gql(node) {
|
|
64
|
+
if (this.config.supermassiveDocumentNodeConditional) {
|
|
65
|
+
const supermassive = this._render(node, true);
|
|
66
|
+
const standard = this._render(node, false);
|
|
67
|
+
return `(${this.config.supermassiveDocumentNodeConditional}
|
|
68
|
+
? ${supermassive}
|
|
69
|
+
: ${standard})`;
|
|
70
|
+
}
|
|
71
|
+
return this._render(node, true);
|
|
72
|
+
}
|
|
73
|
+
_render(node, annotate = false) {
|
|
62
74
|
const supermassiveNode = addTypesToRequestDocument(this._schema, {
|
|
63
75
|
kind: Kind.DOCUMENT,
|
|
64
76
|
definitions: [node]
|
|
@@ -72,7 +84,10 @@ var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
|
|
|
72
84
|
if (this.config.optimizeDocumentNode) {
|
|
73
85
|
gqlObj = optimizeDocumentNode(gqlObj);
|
|
74
86
|
}
|
|
75
|
-
|
|
87
|
+
if (annotate) {
|
|
88
|
+
gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);
|
|
89
|
+
}
|
|
90
|
+
return JSON.stringify(gqlObj);
|
|
76
91
|
} else if (this.config.documentMode === DocumentMode.documentNodeImportFragments) {
|
|
77
92
|
let gqlObj = gqlTag([doc]);
|
|
78
93
|
if (this.config.optimizeDocumentNode) {
|
|
@@ -82,17 +97,20 @@ var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
|
|
|
82
97
|
const definitions = [
|
|
83
98
|
...gqlObj.definitions.map(
|
|
84
99
|
(t) => JSON.stringify(
|
|
85
|
-
addTypesToRequestDocument(this._schema, {
|
|
100
|
+
annotate ? addTypesToRequestDocument(this._schema, {
|
|
86
101
|
kind: Kind.DOCUMENT,
|
|
87
102
|
definitions: [t]
|
|
88
|
-
}).definitions[0]
|
|
103
|
+
}).definitions[0] : t
|
|
89
104
|
)
|
|
90
105
|
),
|
|
91
106
|
...fragments.map((name) => `...${name}.definitions`)
|
|
92
107
|
].join();
|
|
93
108
|
return `{"kind":"${Kind.DOCUMENT}","definitions":[${definitions}]}`;
|
|
94
109
|
}
|
|
95
|
-
|
|
110
|
+
if (annotate) {
|
|
111
|
+
gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);
|
|
112
|
+
}
|
|
113
|
+
return JSON.stringify(gqlObj);
|
|
96
114
|
} else if (this.config.documentMode === DocumentMode.string) {
|
|
97
115
|
return "`" + doc + "`";
|
|
98
116
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphitation/graphql-codegen-supermassive-typed-document-node-plugin",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"main": "./lib/index",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@graphql-codegen/visitor-plugin-common": ">= ^1.17.0 < 2",
|
|
29
29
|
"graphql-tag": ">= 2.11.0 < 3",
|
|
30
30
|
"@graphql-tools/optimize": "^1.0.1",
|
|
31
|
-
"@graphitation/supermassive": "^2.
|
|
31
|
+
"@graphitation/supermassive": "^2.4.0"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"access": "public",
|