@graphitation/graphql-codegen-supermassive-typed-document-node-plugin 0.3.1 → 0.3.3

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 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":2441,"mtime":1678984651877,"results":"3","hashOfConfig":"4"},{"size":4788,"mtime":1678984651881,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1nxtxns",{"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",[]]
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":2441,"mtime":1679998799829,"results":"3","hashOfConfig":"4"},{"size":4788,"mtime":1679998799829,"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,28 @@
1
1
  # Change Log - @graphitation/graphql-codegen-supermassive-typed-document-node-plugin
2
2
 
3
- This log was last generated on Thu, 16 Mar 2023 16:43:58 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 28 Mar 2023 10:27:02 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.3.3
8
+
9
+ Tue, 28 Mar 2023 10:27:02 GMT
10
+
11
+ ### Patches
12
+
13
+ - Bump @graphitation/supermassive to v2.2.3
14
+
15
+ ## 0.3.2
16
+
17
+ Mon, 27 Mar 2023 13:30:13 GMT
18
+
19
+ ### Patches
20
+
21
+ - Bump @graphitation/supermassive to v2.2.2
22
+
7
23
  ## 0.3.1
8
24
 
9
- Thu, 16 Mar 2023 16:43:58 GMT
25
+ Thu, 16 Mar 2023 16:44:10 GMT
10
26
 
11
27
  ### Patches
12
28
 
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -48,7 +49,9 @@ var import_visitor = require("./visitor");
48
49
  const plugin = (schema, documents, config) => {
49
50
  const allAst = (0, import_graphql.concatAST)(documents.map((v) => v.document));
50
51
  const allFragments = [
51
- ...allAst.definitions.filter((d) => d.kind === import_graphql.Kind.FRAGMENT_DEFINITION).map((fragmentDef) => ({
52
+ ...allAst.definitions.filter(
53
+ (d) => d.kind === import_graphql.Kind.FRAGMENT_DEFINITION
54
+ ).map((fragmentDef) => ({
52
55
  node: fragmentDef,
53
56
  name: fragmentDef.name.value,
54
57
  onType: fragmentDef.typeCondition.name.value,
@@ -56,21 +59,32 @@ const plugin = (schema, documents, config) => {
56
59
  })),
57
60
  ...config.externalFragments || []
58
61
  ];
59
- const visitor = new import_visitor.TypeScriptDocumentNodesVisitor(schema, allFragments, config, documents);
62
+ const visitor = new import_visitor.TypeScriptDocumentNodesVisitor(
63
+ schema,
64
+ allFragments,
65
+ config,
66
+ documents
67
+ );
60
68
  const visitorResult = (0, import_graphql.visit)(allAst, { leave: visitor });
61
69
  return {
62
70
  prepend: allAst.definitions.length === 0 ? [] : visitor.getImports(),
63
71
  content: [
64
72
  visitor.fragments,
65
- ...visitorResult.definitions.filter((t) => typeof t === "string")
73
+ ...visitorResult.definitions.filter(
74
+ (t) => typeof t === "string"
75
+ )
66
76
  ].join("\n")
67
77
  };
68
78
  };
69
79
  const validate = (schema, documents, config, outputFile) => __async(void 0, null, function* () {
70
80
  if (config && config.documentMode === import_visitor_plugin_common.DocumentMode.string) {
71
- throw new Error(`Plugin "supermassive-typed-document-node" does not allow using 'documentMode: string' configuration!`);
81
+ throw new Error(
82
+ `Plugin "supermassive-typed-document-node" does not allow using 'documentMode: string' configuration!`
83
+ );
72
84
  }
73
85
  if ((0, import_path.extname)(outputFile) !== ".ts" && (0, import_path.extname)(outputFile) !== ".tsx") {
74
- throw new Error(`Plugin "supermassive-typed-document-node" requires extension to be ".ts" or ".tsx"!`);
86
+ throw new Error(
87
+ `Plugin "supermassive-typed-document-node" requires extension to be ".ts" or ".tsx"!`
88
+ );
75
89
  }
76
90
  });
package/lib/index.mjs CHANGED
@@ -33,7 +33,9 @@ import { TypeScriptDocumentNodesVisitor } from "./visitor.mjs";
33
33
  var plugin = (schema, documents, config) => {
34
34
  const allAst = concatAST(documents.map((v) => v.document));
35
35
  const allFragments = [
36
- ...allAst.definitions.filter((d) => d.kind === Kind.FRAGMENT_DEFINITION).map((fragmentDef) => ({
36
+ ...allAst.definitions.filter(
37
+ (d) => d.kind === Kind.FRAGMENT_DEFINITION
38
+ ).map((fragmentDef) => ({
37
39
  node: fragmentDef,
38
40
  name: fragmentDef.name.value,
39
41
  onType: fragmentDef.typeCondition.name.value,
@@ -41,22 +43,33 @@ var plugin = (schema, documents, config) => {
41
43
  })),
42
44
  ...config.externalFragments || []
43
45
  ];
44
- const visitor = new TypeScriptDocumentNodesVisitor(schema, allFragments, config, documents);
46
+ const visitor = new TypeScriptDocumentNodesVisitor(
47
+ schema,
48
+ allFragments,
49
+ config,
50
+ documents
51
+ );
45
52
  const visitorResult = visit(allAst, { leave: visitor });
46
53
  return {
47
54
  prepend: allAst.definitions.length === 0 ? [] : visitor.getImports(),
48
55
  content: [
49
56
  visitor.fragments,
50
- ...visitorResult.definitions.filter((t) => typeof t === "string")
57
+ ...visitorResult.definitions.filter(
58
+ (t) => typeof t === "string"
59
+ )
51
60
  ].join("\n")
52
61
  };
53
62
  };
54
63
  var validate = (schema, documents, config, outputFile) => __async(void 0, null, function* () {
55
64
  if (config && config.documentMode === DocumentMode.string) {
56
- throw new Error(`Plugin "supermassive-typed-document-node" does not allow using 'documentMode: string' configuration!`);
65
+ throw new Error(
66
+ `Plugin "supermassive-typed-document-node" does not allow using 'documentMode: string' configuration!`
67
+ );
57
68
  }
58
69
  if (extname(outputFile) !== ".ts" && extname(outputFile) !== ".tsx") {
59
- throw new Error(`Plugin "supermassive-typed-document-node" requires extension to be ".ts" or ".tsx"!`);
70
+ throw new Error(
71
+ `Plugin "supermassive-typed-document-node" requires extension to be ".ts" or ".tsx"!`
72
+ );
60
73
  }
61
74
  });
62
75
  export {
package/lib/visitor.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __defProps = Object.defineProperties;
@@ -33,7 +34,14 @@ var __copyProps = (to, from, except, desc) => {
33
34
  }
34
35
  return to;
35
36
  };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
37
45
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
46
  var visitor_exports = {};
39
47
  __export(visitor_exports, {
@@ -48,14 +56,26 @@ var import_optimize = require("@graphql-tools/optimize");
48
56
  var import_graphql_tag = __toESM(require("graphql-tag"));
49
57
  class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.ClientSideBaseVisitor {
50
58
  constructor(schema, fragments, rawConfig, documents) {
51
- super(schema, fragments, __spreadValues({
52
- documentMode: import_visitor_plugin_common.DocumentMode.documentNodeImportFragments,
53
- documentNodeImport: "@graphql-typed-document-node/core#TypedDocumentNode"
54
- }, rawConfig), {}, documents);
59
+ super(
60
+ schema,
61
+ fragments,
62
+ __spreadValues({
63
+ documentMode: import_visitor_plugin_common.DocumentMode.documentNodeImportFragments,
64
+ documentNodeImport: "@graphql-typed-document-node/core#TypedDocumentNode"
65
+ }, rawConfig),
66
+ {},
67
+ documents
68
+ );
55
69
  (0, import_auto_bind.default)(this);
56
70
  if (this.config.documentMode === import_visitor_plugin_common.DocumentMode.graphQLTag) {
57
- const documentNodeImport = this._parseImport(this.config.documentNodeImport || "graphql#DocumentNode");
58
- const tagImport = this._generateImport(documentNodeImport, "DocumentNode", true);
71
+ const documentNodeImport = this._parseImport(
72
+ this.config.documentNodeImport || "graphql#DocumentNode"
73
+ );
74
+ const tagImport = this._generateImport(
75
+ documentNodeImport,
76
+ "DocumentNode",
77
+ true
78
+ );
59
79
  this._imports.add(tagImport);
60
80
  }
61
81
  }
@@ -81,10 +101,14 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
81
101
  }
82
102
  if (fragments.length > 0) {
83
103
  const definitions = [
84
- ...gqlObj.definitions.map((t) => JSON.stringify((0, import_supermassive.addTypesToRequestDocument)(this._schema, {
85
- kind: import_graphql.Kind.DOCUMENT,
86
- definitions: [t]
87
- }).definitions[0])),
104
+ ...gqlObj.definitions.map(
105
+ (t) => JSON.stringify(
106
+ (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
107
+ kind: import_graphql.Kind.DOCUMENT,
108
+ definitions: [t]
109
+ }).definitions[0]
110
+ )
111
+ ),
88
112
  ...fragments.map((name) => `...${name}.definitions`)
89
113
  ].join();
90
114
  return `{"kind":"${import_graphql.Kind.DOCUMENT}","definitions":[${definitions}]}`;
@@ -98,10 +122,12 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
98
122
  }
99
123
  _transformDocumentNodeToSupermassive(document) {
100
124
  return __spreadProps(__spreadValues({}, document), {
101
- definitions: document.definitions.map((t) => (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
102
- kind: import_graphql.Kind.DOCUMENT,
103
- definitions: [t]
104
- }).definitions[0])
125
+ definitions: document.definitions.map(
126
+ (t) => (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
127
+ kind: import_graphql.Kind.DOCUMENT,
128
+ definitions: [t]
129
+ }).definitions[0]
130
+ )
105
131
  });
106
132
  }
107
133
  getDocumentNodeSignature(resultType, variablesTypes, node) {
package/lib/visitor.mjs CHANGED
@@ -35,14 +35,26 @@ import { optimizeDocumentNode } from "@graphql-tools/optimize";
35
35
  import gqlTag from "graphql-tag";
36
36
  var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
37
37
  constructor(schema, fragments, rawConfig, documents) {
38
- super(schema, fragments, __spreadValues({
39
- documentMode: DocumentMode.documentNodeImportFragments,
40
- documentNodeImport: "@graphql-typed-document-node/core#TypedDocumentNode"
41
- }, rawConfig), {}, documents);
38
+ super(
39
+ schema,
40
+ fragments,
41
+ __spreadValues({
42
+ documentMode: DocumentMode.documentNodeImportFragments,
43
+ documentNodeImport: "@graphql-typed-document-node/core#TypedDocumentNode"
44
+ }, rawConfig),
45
+ {},
46
+ documents
47
+ );
42
48
  autoBind(this);
43
49
  if (this.config.documentMode === DocumentMode.graphQLTag) {
44
- const documentNodeImport = this._parseImport(this.config.documentNodeImport || "graphql#DocumentNode");
45
- const tagImport = this._generateImport(documentNodeImport, "DocumentNode", true);
50
+ const documentNodeImport = this._parseImport(
51
+ this.config.documentNodeImport || "graphql#DocumentNode"
52
+ );
53
+ const tagImport = this._generateImport(
54
+ documentNodeImport,
55
+ "DocumentNode",
56
+ true
57
+ );
46
58
  this._imports.add(tagImport);
47
59
  }
48
60
  }
@@ -68,10 +80,14 @@ var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
68
80
  }
69
81
  if (fragments.length > 0) {
70
82
  const definitions = [
71
- ...gqlObj.definitions.map((t) => JSON.stringify(addTypesToRequestDocument(this._schema, {
72
- kind: Kind.DOCUMENT,
73
- definitions: [t]
74
- }).definitions[0])),
83
+ ...gqlObj.definitions.map(
84
+ (t) => JSON.stringify(
85
+ addTypesToRequestDocument(this._schema, {
86
+ kind: Kind.DOCUMENT,
87
+ definitions: [t]
88
+ }).definitions[0]
89
+ )
90
+ ),
75
91
  ...fragments.map((name) => `...${name}.definitions`)
76
92
  ].join();
77
93
  return `{"kind":"${Kind.DOCUMENT}","definitions":[${definitions}]}`;
@@ -85,10 +101,12 @@ var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
85
101
  }
86
102
  _transformDocumentNodeToSupermassive(document) {
87
103
  return __spreadProps(__spreadValues({}, document), {
88
- definitions: document.definitions.map((t) => addTypesToRequestDocument(this._schema, {
89
- kind: Kind.DOCUMENT,
90
- definitions: [t]
91
- }).definitions[0])
104
+ definitions: document.definitions.map(
105
+ (t) => addTypesToRequestDocument(this._schema, {
106
+ kind: Kind.DOCUMENT,
107
+ definitions: [t]
108
+ }).definitions[0]
109
+ )
92
110
  });
93
111
  }
94
112
  getDocumentNodeSignature(resultType, variablesTypes, node) {
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.3.1",
4
+ "version": "0.3.3",
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.2.1"
31
+ "@graphitation/supermassive": "^2.2.3"
32
32
  },
33
33
  "sideEffects": false,
34
34
  "access": "public",