@graphitation/graphql-codegen-supermassive-typed-document-node-plugin 0.4.7 → 0.5.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 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":2430,"mtime":1686127466389,"results":"3","hashOfConfig":"4"},{"size":5684,"mtime":1686127466389,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","suppressedMessages":"8","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"15p4zzk",{"filePath":"9","messages":"10","suppressedMessages":"11","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":2430,"mtime":1687177066340,"results":"3","hashOfConfig":"4"},{"size":5688,"mtime":1687177066340,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","suppressedMessages":"8","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1l9rojw",{"filePath":"9","messages":"10","suppressedMessages":"11","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 Wed, 07 Jun 2023 08:48:11 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 19 Jun 2023 12:22:02 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.5.0
8
+
9
+ Mon, 19 Jun 2023 12:22:02 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Move to supermassive-ast package (mnovikov@microsoft.com)
14
+ - Bump @graphitation/supermassive-ast to v2.0.0
15
+
16
+ ## 0.4.8
17
+
18
+ Mon, 12 Jun 2023 12:50:51 GMT
19
+
20
+ ### Patches
21
+
22
+ - Bump @graphitation/supermassive to v2.4.8
23
+
7
24
  ## 0.4.7
8
25
 
9
- Wed, 07 Jun 2023 08:48:11 GMT
26
+ Wed, 07 Jun 2023 08:48:18 GMT
10
27
 
11
28
  ### Patches
12
29
 
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/*\n * Taken from https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/packages/plugins/typescript/typed-document-node/src/index.ts\n * MIT license https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/LICENSE\n */\n\nimport {\n Types,\n PluginValidateFn,\n PluginFunction,\n} from \"@graphql-codegen/plugin-helpers\";\nimport {\n visit,\n concatAST,\n GraphQLSchema,\n Kind,\n FragmentDefinitionNode,\n DocumentNode,\n DefinitionNode,\n} from \"graphql\";\nimport { extname } from \"path\";\nimport {\n LoadedFragment,\n RawClientSideBasePluginConfig,\n DocumentMode,\n} from \"@graphql-codegen/visitor-plugin-common\";\nimport { TypeScriptDocumentNodesVisitor } from \"./visitor\";\n\nexport const plugin: PluginFunction<RawClientSideBasePluginConfig> = (\n schema: GraphQLSchema,\n documents: Types.DocumentFile[],\n config: RawClientSideBasePluginConfig,\n) => {\n const allAst = concatAST(documents.map((v) => v.document as DocumentNode));\n\n const allFragments: LoadedFragment[] = [\n ...(\n allAst.definitions.filter(\n (d) => d.kind === Kind.FRAGMENT_DEFINITION,\n ) as FragmentDefinitionNode[]\n ).map((fragmentDef) => ({\n node: fragmentDef,\n name: fragmentDef.name.value,\n onType: fragmentDef.typeCondition.name.value,\n isExternal: false,\n })),\n ...(config.externalFragments || []),\n ];\n\n const visitor = new TypeScriptDocumentNodesVisitor(\n schema,\n allFragments,\n config,\n documents,\n );\n const visitorResult = visit(allAst, { leave: visitor });\n\n return {\n prepend: allAst.definitions.length === 0 ? [] : visitor.getImports(),\n content: [\n visitor.fragments,\n ...visitorResult.definitions.filter(\n (t: DefinitionNode) => typeof t === \"string\",\n ),\n ].join(\"\\n\"),\n };\n};\n\nexport const validate: PluginValidateFn<RawClientSideBasePluginConfig> = async (\n schema: GraphQLSchema,\n documents: Types.DocumentFile[],\n config,\n outputFile: string,\n) => {\n if (config && config.documentMode === DocumentMode.string) {\n throw new Error(\n `Plugin \"supermassive-typed-document-node\" does not allow using 'documentMode: string' configuration!`,\n );\n }\n\n if (extname(outputFile) !== \".ts\" && extname(outputFile) !== \".tsx\") {\n throw new Error(\n `Plugin \"supermassive-typed-document-node\" requires extension to be \".ts\" or \".tsx\"!`,\n );\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,qBAQO;AACP,kBAAwB;AACxB,mCAIO;AACP,qBAA+C;AAExC,MAAM,SAAwD,CACnE,QACA,WACA,WACG;AACH,QAAM,aAAS,0BAAU,UAAU,IAAI,CAAC,MAAM,EAAE,QAAwB,CAAC;AAEzE,QAAM,eAAiC;AAAA,IACrC,GACE,OAAO,YAAY;AAAA,MACjB,CAAC,MAAM,EAAE,SAAS,oBAAK;AAAA,IACzB,EACA,IAAI,CAAC,iBAAiB;AAAA,MACtB,MAAM;AAAA,MACN,MAAM,YAAY,KAAK;AAAA,MACvB,QAAQ,YAAY,cAAc,KAAK;AAAA,MACvC,YAAY;AAAA,IACd,EAAE;AAAA,IACF,GAAI,OAAO,qBAAqB,CAAC;AAAA,EACnC;AAEA,QAAM,UAAU,IAAI;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,oBAAgB,sBAAM,QAAQ,EAAE,OAAO,QAAQ,CAAC;AAEtD,SAAO;AAAA,IACL,SAAS,OAAO,YAAY,WAAW,IAAI,CAAC,IAAI,QAAQ,WAAW;AAAA,IACnE,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,cAAc,YAAY;AAAA,QAC3B,CAAC,MAAsB,OAAO,MAAM;AAAA,MACtC;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,WAA4D,CACvE,QACA,WACA,QACA,eACG;AACH,MAAI,UAAU,OAAO,iBAAiB,0CAAa,QAAQ;AACzD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,UAAI,qBAAQ,UAAU,MAAM,aAAS,qBAAQ,UAAU,MAAM,QAAQ;AACnE,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/*\n * Taken from https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/packages/plugins/typescript/typed-document-node/src/index.ts\n * MIT license https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/LICENSE\n */\n\nimport {\n Types,\n PluginValidateFn,\n PluginFunction,\n} from \"@graphql-codegen/plugin-helpers\";\nimport {\n visit,\n concatAST,\n GraphQLSchema,\n Kind,\n FragmentDefinitionNode,\n DocumentNode,\n DefinitionNode,\n} from \"graphql\";\nimport { extname } from \"path\";\nimport {\n LoadedFragment,\n RawClientSideBasePluginConfig,\n DocumentMode,\n} from \"@graphql-codegen/visitor-plugin-common\";\nimport { TypeScriptDocumentNodesVisitor } from \"./visitor\";\n\nexport const plugin: PluginFunction<RawClientSideBasePluginConfig> = (\n schema: GraphQLSchema,\n documents: Types.DocumentFile[],\n config: RawClientSideBasePluginConfig,\n) => {\n const allAst = concatAST(documents.map((v) => v.document as DocumentNode));\n\n const allFragments: LoadedFragment[] = [\n ...(\n allAst.definitions.filter(\n (d) => d.kind === Kind.FRAGMENT_DEFINITION,\n ) as FragmentDefinitionNode[]\n ).map((fragmentDef) => ({\n node: fragmentDef,\n name: fragmentDef.name.value,\n onType: fragmentDef.typeCondition.name.value,\n isExternal: false,\n })),\n ...(config.externalFragments || []),\n ];\n\n const visitor = new TypeScriptDocumentNodesVisitor(\n schema,\n allFragments,\n config,\n documents,\n );\n const visitorResult = visit(allAst, { leave: visitor });\n\n return {\n prepend: allAst.definitions.length === 0 ? [] : visitor.getImports(),\n content: [\n visitor.fragments,\n ...visitorResult.definitions.filter(\n (t: DefinitionNode) => typeof t === \"string\",\n ),\n ].join(\"\\n\"),\n };\n};\n\nexport const validate: PluginValidateFn<RawClientSideBasePluginConfig> = async (\n schema: GraphQLSchema,\n documents: Types.DocumentFile[],\n config,\n outputFile: string,\n) => {\n if (config && config.documentMode === DocumentMode.string) {\n throw new Error(\n `Plugin \"supermassive-typed-document-node\" does not allow using 'documentMode: string' configuration!`,\n );\n }\n\n if (extname(outputFile) !== \".ts\" && extname(outputFile) !== \".tsx\") {\n throw new Error(\n `Plugin \"supermassive-typed-document-node\" requires extension to be \".ts\" or \".tsx\"!`,\n );\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OAIK;AACP,SAAS,eAAe;AACxB;AAAA,EAGE;AAAA,OACK;AACP,SAAS,sCAAsC;AAExC,IAAM,SAAwD,CACnE,QACA,WACA,WACG;AACH,QAAM,SAAS,UAAU,UAAU,IAAI,CAAC,MAAM,EAAE,QAAwB,CAAC;AAEzE,QAAM,eAAiC;AAAA,IACrC,GACE,OAAO,YAAY;AAAA,MACjB,CAAC,MAAM,EAAE,SAAS,KAAK;AAAA,IACzB,EACA,IAAI,CAAC,iBAAiB;AAAA,MACtB,MAAM;AAAA,MACN,MAAM,YAAY,KAAK;AAAA,MACvB,QAAQ,YAAY,cAAc,KAAK;AAAA,MACvC,YAAY;AAAA,IACd,EAAE;AAAA,IACF,GAAI,OAAO,qBAAqB,CAAC;AAAA,EACnC;AAEA,QAAM,UAAU,IAAI;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,gBAAgB,MAAM,QAAQ,EAAE,OAAO,QAAQ,CAAC;AAEtD,SAAO;AAAA,IACL,SAAS,OAAO,YAAY,WAAW,IAAI,CAAC,IAAI,QAAQ,WAAW;AAAA,IACnE,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,cAAc,YAAY;AAAA,QAC3B,CAAC,MAAsB,OAAO,MAAM;AAAA,MACtC;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,IAAM,WAA4D,CACvE,QACA,WACA,QACA,eACG;AACH,MAAI,UAAU,OAAO,iBAAiB,aAAa,QAAQ;AACzD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,QAAQ,UAAU,MAAM,SAAS,QAAQ,UAAU,MAAM,QAAQ;AACnE,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
package/lib/visitor.js CHANGED
@@ -51,7 +51,7 @@ module.exports = __toCommonJS(visitor_exports);
51
51
  var import_auto_bind = __toESM(require("auto-bind"));
52
52
  var import_visitor_plugin_common = require("@graphql-codegen/visitor-plugin-common");
53
53
  var import_graphql = require("graphql");
54
- var import_supermassive = require("@graphitation/supermassive");
54
+ var import_supermassive_ast = require("@graphitation/supermassive-ast");
55
55
  var import_optimize = require("@graphql-tools/optimize");
56
56
  var import_graphql_tag = __toESM(require("graphql-tag"));
57
57
  class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.ClientSideBaseVisitor {
@@ -92,7 +92,7 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
92
92
  return this._render(node, true);
93
93
  }
94
94
  _render(node, annotate = false) {
95
- const supermassiveNode = (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
95
+ const supermassiveNode = (0, import_supermassive_ast.addTypesToRequestDocument)(this._schema, {
96
96
  kind: import_graphql.Kind.DOCUMENT,
97
97
  definitions: [node]
98
98
  }).definitions[0];
@@ -118,7 +118,7 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
118
118
  const definitions = [
119
119
  ...gqlObj.definitions.map(
120
120
  (t) => JSON.stringify(
121
- annotate ? (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
121
+ annotate ? (0, import_supermassive_ast.addTypesToRequestDocument)(this._schema, {
122
122
  kind: import_graphql.Kind.DOCUMENT,
123
123
  definitions: [t]
124
124
  }).definitions[0] : t
@@ -141,7 +141,7 @@ class TypeScriptDocumentNodesVisitor extends import_visitor_plugin_common.Client
141
141
  _transformDocumentNodeToSupermassive(document) {
142
142
  return __spreadProps(__spreadValues({}, document), {
143
143
  definitions: document.definitions.map(
144
- (t) => (0, import_supermassive.addTypesToRequestDocument)(this._schema, {
144
+ (t) => (0, import_supermassive_ast.addTypesToRequestDocument)(this._schema, {
145
145
  kind: import_graphql.Kind.DOCUMENT,
146
146
  definitions: [t]
147
147
  }).definitions[0]
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/visitor.ts"],
4
+ "sourcesContent": ["/*\n * Taken from https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/packages/plugins/typescript/typed-document-node/src/visitor.ts\n * MIT license https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/LICENSE\n */\n\nimport autoBind from \"auto-bind\";\nimport { Types } from \"@graphql-codegen/plugin-helpers\";\nimport {\n LoadedFragment,\n ClientSideBaseVisitor,\n ClientSideBasePluginConfig,\n DocumentMode,\n RawClientSideBasePluginConfig,\n} from \"@graphql-codegen/visitor-plugin-common\";\nimport {\n GraphQLSchema,\n FragmentDefinitionNode,\n DocumentNode,\n print,\n Kind,\n OperationDefinitionNode,\n} from \"graphql\";\nimport { addTypesToRequestDocument } from \"@graphitation/supermassive-ast\";\nimport { optimizeDocumentNode } from \"@graphql-tools/optimize\";\nimport gqlTag from \"graphql-tag\";\n\ntype RawClientSidePluginConfig = RawClientSideBasePluginConfig & {\n supermassiveDocumentNodeConditional?: string;\n};\ntype ClientSidePluginConfig = ClientSideBasePluginConfig & {\n supermassiveDocumentNodeConditional?: string;\n};\n\nexport class TypeScriptDocumentNodesVisitor extends ClientSideBaseVisitor<\n RawClientSidePluginConfig,\n ClientSidePluginConfig\n> {\n constructor(\n schema: GraphQLSchema,\n fragments: LoadedFragment[],\n rawConfig: RawClientSidePluginConfig,\n documents: Types.DocumentFile[],\n ) {\n super(\n schema,\n fragments,\n {\n documentMode: DocumentMode.documentNodeImportFragments,\n documentNodeImport:\n \"@graphql-typed-document-node/core#TypedDocumentNode\",\n ...rawConfig,\n },\n {\n supermassiveDocumentNodeConditional:\n rawConfig.supermassiveDocumentNodeConditional,\n },\n documents,\n );\n\n autoBind(this);\n\n // We need to make sure it's there because in this mode, the base plugin doesn't add the import\n if (this.config.documentMode === DocumentMode.graphQLTag) {\n const documentNodeImport = this._parseImport(\n this.config.documentNodeImport || \"graphql#DocumentNode\",\n );\n const tagImport = this._generateImport(\n documentNodeImport,\n \"DocumentNode\",\n true,\n ) as string;\n this._imports.add(tagImport);\n }\n }\n\n protected _gql(\n node: FragmentDefinitionNode | OperationDefinitionNode,\n ): string {\n if (this.config.supermassiveDocumentNodeConditional) {\n const supermassive = this._render(node, true);\n const standard = this._render(node, false);\n return `(${this.config.supermassiveDocumentNodeConditional}\\n? ${supermassive}\\n: ${standard})`;\n }\n return this._render(node, true);\n }\n\n protected _render(\n node: FragmentDefinitionNode | OperationDefinitionNode,\n annotate = false,\n ): string {\n const supermassiveNode = addTypesToRequestDocument(this._schema, {\n kind: Kind.DOCUMENT,\n definitions: [node],\n }).definitions[0] as FragmentDefinitionNode | OperationDefinitionNode;\n\n const fragments = this._transformFragments(supermassiveNode);\n\n const doc = this._prepareDocument(`\n ${\n print(supermassiveNode)\n .split(\"\\\\\")\n .join(\"\\\\\\\\\") /* Re-escape escaped values in GraphQL syntax */\n }\n ${this._includeFragments(fragments)}`);\n\n if (this.config.documentMode === DocumentMode.documentNode) {\n let gqlObj = gqlTag([doc]);\n\n if (this.config.optimizeDocumentNode) {\n gqlObj = optimizeDocumentNode(gqlObj);\n }\n if (annotate) {\n gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);\n }\n\n return JSON.stringify(gqlObj);\n } else if (\n this.config.documentMode === DocumentMode.documentNodeImportFragments\n ) {\n let gqlObj = gqlTag([doc]);\n\n if (this.config.optimizeDocumentNode) {\n gqlObj = optimizeDocumentNode(gqlObj);\n }\n\n if (fragments.length > 0) {\n const definitions = [\n ...gqlObj.definitions.map((t) =>\n JSON.stringify(\n annotate\n ? addTypesToRequestDocument(this._schema, {\n kind: Kind.DOCUMENT,\n definitions: [t],\n }).definitions[0]\n : t,\n ),\n ),\n ...fragments.map((name) => `...${name}.definitions`),\n ].join();\n\n return `{\"kind\":\"${Kind.DOCUMENT}\",\"definitions\":[${definitions}]}`;\n }\n if (annotate) {\n gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);\n }\n\n return JSON.stringify(gqlObj);\n } else if (this.config.documentMode === DocumentMode.string) {\n return \"`\" + doc + \"`\";\n }\n\n const gqlImport = this._parseImport(this.config.gqlImport || \"graphql-tag\");\n\n return (gqlImport.propName || \"gql\") + \"`\" + doc + \"`\";\n }\n\n private _transformDocumentNodeToSupermassive(document: DocumentNode) {\n return {\n ...document,\n definitions: document.definitions.map(\n (t) =>\n addTypesToRequestDocument(this._schema, {\n kind: Kind.DOCUMENT,\n definitions: [t],\n }).definitions[0],\n ),\n } as DocumentNode;\n }\n protected getDocumentNodeSignature(\n resultType: string,\n variablesTypes: string,\n node: FragmentDefinitionNode | OperationDefinitionNode,\n ) {\n if (\n this.config.documentMode === DocumentMode.documentNode ||\n this.config.documentMode === DocumentMode.documentNodeImportFragments ||\n this.config.documentMode === DocumentMode.graphQLTag\n ) {\n return ` as unknown as DocumentNode<${resultType}, ${variablesTypes}>`;\n }\n\n return super.getDocumentNodeSignature(resultType, variablesTypes, node);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,uBAAqB;AAErB,mCAMO;AACP,qBAOO;AACP,8BAA0C;AAC1C,sBAAqC;AACrC,yBAAmB;AASZ,MAAM,uCAAuC,mDAGlD;AAAA,EACA,YACE,QACA,WACA,WACA,WACA;AACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,QACE,cAAc,0CAAa;AAAA,QAC3B,oBACE;AAAA,SACC;AAAA,MAEL;AAAA,QACE,qCACE,UAAU;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAEA,yBAAAA,SAAS,IAAI;AAGb,QAAI,KAAK,OAAO,iBAAiB,0CAAa,YAAY;AACxD,YAAM,qBAAqB,KAAK;AAAA,QAC9B,KAAK,OAAO,sBAAsB;AAAA,MACpC;AACA,YAAM,YAAY,KAAK;AAAA,QACrB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,WAAK,SAAS,IAAI,SAAS;AAAA,IAC7B;AAAA,EACF;AAAA,EAEU,KACR,MACQ;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CAAC,EAAE,YAAY,CAAC,IAChB;AAAA,YACN;AAAA,UACF;AAAA,UACA,GAAG,UAAU,IAAI,CAAC,SAAS,MAAM,kBAAkB;AAAA,QACrD,EAAE,KAAK;AAEP,eAAO,YAAY,oBAAK,4BAA4B;AAAA,MACtD;AACA,UAAI,UAAU;AACZ,iBAAS,KAAK,qCAAqC,MAAM;AAAA,MAC3D;AAEA,aAAO,KAAK,UAAU,MAAM;AAAA,IAC9B,WAAW,KAAK,OAAO,iBAAiB,0CAAa,QAAQ;AAC3D,aAAO,MAAM,MAAM;AAAA,IACrB;AAEA,UAAM,YAAY,KAAK,aAAa,KAAK,OAAO,aAAa,aAAa;AAE1E,YAAQ,UAAU,YAAY,SAAS,MAAM,MAAM;AAAA,EACrD;AAAA,EAEQ,qCAAqC,UAAwB;AACnE,WAAO,iCACF,WADE;AAAA,MAEL,aAAa,SAAS,YAAY;AAAA,QAChC,CAAC,UACC,mDAA0B,KAAK,SAAS;AAAA,UACtC,MAAM,oBAAK;AAAA,UACX,aAAa,CAAC,CAAC;AAAA,QACjB,CAAC,EAAE,YAAY,CAAC;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAAA,EACU,yBACR,YACA,gBACA,MACA;AACA,QACE,KAAK,OAAO,iBAAiB,0CAAa,gBAC1C,KAAK,OAAO,iBAAiB,0CAAa,+BAC1C,KAAK,OAAO,iBAAiB,0CAAa,YAC1C;AACA,aAAO,+BAA+B,eAAe;AAAA,IACvD;AAEA,WAAO,MAAM,yBAAyB,YAAY,gBAAgB,IAAI;AAAA,EACxE;AACF;",
6
+ "names": ["autoBind", "gqlTag"]
7
+ }
package/lib/visitor.mjs CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  print,
29
29
  Kind
30
30
  } from "graphql";
31
- import { addTypesToRequestDocument } from "@graphitation/supermassive";
31
+ import { addTypesToRequestDocument } from "@graphitation/supermassive-ast";
32
32
  import { optimizeDocumentNode } from "@graphql-tools/optimize";
33
33
  import gqlTag from "graphql-tag";
34
34
  var TypeScriptDocumentNodesVisitor = class extends ClientSideBaseVisitor {
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/visitor.ts"],
4
+ "sourcesContent": ["/*\n * Taken from https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/packages/plugins/typescript/typed-document-node/src/visitor.ts\n * MIT license https://github.com/dotansimha/graphql-code-generator/blob/4fee8c8c523b30163e913438b85a064c58e39087/LICENSE\n */\n\nimport autoBind from \"auto-bind\";\nimport { Types } from \"@graphql-codegen/plugin-helpers\";\nimport {\n LoadedFragment,\n ClientSideBaseVisitor,\n ClientSideBasePluginConfig,\n DocumentMode,\n RawClientSideBasePluginConfig,\n} from \"@graphql-codegen/visitor-plugin-common\";\nimport {\n GraphQLSchema,\n FragmentDefinitionNode,\n DocumentNode,\n print,\n Kind,\n OperationDefinitionNode,\n} from \"graphql\";\nimport { addTypesToRequestDocument } from \"@graphitation/supermassive-ast\";\nimport { optimizeDocumentNode } from \"@graphql-tools/optimize\";\nimport gqlTag from \"graphql-tag\";\n\ntype RawClientSidePluginConfig = RawClientSideBasePluginConfig & {\n supermassiveDocumentNodeConditional?: string;\n};\ntype ClientSidePluginConfig = ClientSideBasePluginConfig & {\n supermassiveDocumentNodeConditional?: string;\n};\n\nexport class TypeScriptDocumentNodesVisitor extends ClientSideBaseVisitor<\n RawClientSidePluginConfig,\n ClientSidePluginConfig\n> {\n constructor(\n schema: GraphQLSchema,\n fragments: LoadedFragment[],\n rawConfig: RawClientSidePluginConfig,\n documents: Types.DocumentFile[],\n ) {\n super(\n schema,\n fragments,\n {\n documentMode: DocumentMode.documentNodeImportFragments,\n documentNodeImport:\n \"@graphql-typed-document-node/core#TypedDocumentNode\",\n ...rawConfig,\n },\n {\n supermassiveDocumentNodeConditional:\n rawConfig.supermassiveDocumentNodeConditional,\n },\n documents,\n );\n\n autoBind(this);\n\n // We need to make sure it's there because in this mode, the base plugin doesn't add the import\n if (this.config.documentMode === DocumentMode.graphQLTag) {\n const documentNodeImport = this._parseImport(\n this.config.documentNodeImport || \"graphql#DocumentNode\",\n );\n const tagImport = this._generateImport(\n documentNodeImport,\n \"DocumentNode\",\n true,\n ) as string;\n this._imports.add(tagImport);\n }\n }\n\n protected _gql(\n node: FragmentDefinitionNode | OperationDefinitionNode,\n ): string {\n if (this.config.supermassiveDocumentNodeConditional) {\n const supermassive = this._render(node, true);\n const standard = this._render(node, false);\n return `(${this.config.supermassiveDocumentNodeConditional}\\n? ${supermassive}\\n: ${standard})`;\n }\n return this._render(node, true);\n }\n\n protected _render(\n node: FragmentDefinitionNode | OperationDefinitionNode,\n annotate = false,\n ): string {\n const supermassiveNode = addTypesToRequestDocument(this._schema, {\n kind: Kind.DOCUMENT,\n definitions: [node],\n }).definitions[0] as FragmentDefinitionNode | OperationDefinitionNode;\n\n const fragments = this._transformFragments(supermassiveNode);\n\n const doc = this._prepareDocument(`\n ${\n print(supermassiveNode)\n .split(\"\\\\\")\n .join(\"\\\\\\\\\") /* Re-escape escaped values in GraphQL syntax */\n }\n ${this._includeFragments(fragments)}`);\n\n if (this.config.documentMode === DocumentMode.documentNode) {\n let gqlObj = gqlTag([doc]);\n\n if (this.config.optimizeDocumentNode) {\n gqlObj = optimizeDocumentNode(gqlObj);\n }\n if (annotate) {\n gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);\n }\n\n return JSON.stringify(gqlObj);\n } else if (\n this.config.documentMode === DocumentMode.documentNodeImportFragments\n ) {\n let gqlObj = gqlTag([doc]);\n\n if (this.config.optimizeDocumentNode) {\n gqlObj = optimizeDocumentNode(gqlObj);\n }\n\n if (fragments.length > 0) {\n const definitions = [\n ...gqlObj.definitions.map((t) =>\n JSON.stringify(\n annotate\n ? addTypesToRequestDocument(this._schema, {\n kind: Kind.DOCUMENT,\n definitions: [t],\n }).definitions[0]\n : t,\n ),\n ),\n ...fragments.map((name) => `...${name}.definitions`),\n ].join();\n\n return `{\"kind\":\"${Kind.DOCUMENT}\",\"definitions\":[${definitions}]}`;\n }\n if (annotate) {\n gqlObj = this._transformDocumentNodeToSupermassive(gqlObj);\n }\n\n return JSON.stringify(gqlObj);\n } else if (this.config.documentMode === DocumentMode.string) {\n return \"`\" + doc + \"`\";\n }\n\n const gqlImport = this._parseImport(this.config.gqlImport || \"graphql-tag\");\n\n return (gqlImport.propName || \"gql\") + \"`\" + doc + \"`\";\n }\n\n private _transformDocumentNodeToSupermassive(document: DocumentNode) {\n return {\n ...document,\n definitions: document.definitions.map(\n (t) =>\n addTypesToRequestDocument(this._schema, {\n kind: Kind.DOCUMENT,\n definitions: [t],\n }).definitions[0],\n ),\n } as DocumentNode;\n }\n protected getDocumentNodeSignature(\n resultType: string,\n variablesTypes: string,\n node: FragmentDefinitionNode | OperationDefinitionNode,\n ) {\n if (\n this.config.documentMode === DocumentMode.documentNode ||\n this.config.documentMode === DocumentMode.documentNodeImportFragments ||\n this.config.documentMode === DocumentMode.graphQLTag\n ) {\n return ` as unknown as DocumentNode<${resultType}, ${variablesTypes}>`;\n }\n\n return super.getDocumentNodeSignature(resultType, variablesTypes, node);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,cAAc;AAErB;AAAA,EAEE;AAAA,EAEA;AAAA,OAEK;AACP;AAAA,EAIE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AACrC,OAAO,YAAY;AASZ,IAAM,iCAAN,cAA6C,sBAGlD;AAAA,EACA,YACE,QACA,WACA,WACA,WACA;AACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,QACE,cAAc,aAAa;AAAA,QAC3B,oBACE;AAAA,SACC;AAAA,MAEL;AAAA,QACE,qCACE,UAAU;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAEA,aAAS,IAAI;AAGb,QAAI,KAAK,OAAO,iBAAiB,aAAa,YAAY;AACxD,YAAM,qBAAqB,KAAK;AAAA,QAC9B,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,GAAG,OAAO,YAAY;AAAA,YAAI,CAAC,MACzB,KAAK;AAAA,cACH,WACI,0BAA0B,KAAK,SAAS;AAAA,gBACtC,MAAM,KAAK;AAAA,gBACX,aAAa,CAAC,CAAC;AAAA,cACjB,CAAC,EAAE,YAAY,CAAC,IAChB;AAAA,YACN;AAAA,UACF;AAAA,UACA,GAAG,UAAU,IAAI,CAAC,SAAS,MAAM,kBAAkB;AAAA,QACrD,EAAE,KAAK;AAEP,eAAO,YAAY,KAAK,4BAA4B;AAAA,MACtD;AACA,UAAI,UAAU;AACZ,iBAAS,KAAK,qCAAqC,MAAM;AAAA,MAC3D;AAEA,aAAO,KAAK,UAAU,MAAM;AAAA,IAC9B,WAAW,KAAK,OAAO,iBAAiB,aAAa,QAAQ;AAC3D,aAAO,MAAM,MAAM;AAAA,IACrB;AAEA,UAAM,YAAY,KAAK,aAAa,KAAK,OAAO,aAAa,aAAa;AAE1E,YAAQ,UAAU,YAAY,SAAS,MAAM,MAAM;AAAA,EACrD;AAAA,EAEQ,qCAAqC,UAAwB;AACnE,WAAO,iCACF,WADE;AAAA,MAEL,aAAa,SAAS,YAAY;AAAA,QAChC,CAAC,MACC,0BAA0B,KAAK,SAAS;AAAA,UACtC,MAAM,KAAK;AAAA,UACX,aAAa,CAAC,CAAC;AAAA,QACjB,CAAC,EAAE,YAAY,CAAC;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAAA,EACU,yBACR,YACA,gBACA,MACA;AACA,QACE,KAAK,OAAO,iBAAiB,aAAa,gBAC1C,KAAK,OAAO,iBAAiB,aAAa,+BAC1C,KAAK,OAAO,iBAAiB,aAAa,YAC1C;AACA,aAAO,+BAA+B,eAAe;AAAA,IACvD;AAEA,WAAO,MAAM,yBAAyB,YAAY,gBAAgB,IAAI;AAAA,EACxE;AACF;",
6
+ "names": []
7
+ }
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.7",
4
+ "version": "0.5.0",
5
5
  "main": "./lib/index",
6
6
  "repository": {
7
7
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  "just": "monorepo-scripts"
16
16
  },
17
17
  "devDependencies": {
18
- "@graphitation/supermassive": "*",
18
+ "@graphitation/supermassive-ast": "*",
19
19
  "@graphql-codegen/plugin-helpers": "^1.18.2",
20
20
  "@graphql-codegen/visitor-plugin-common": "^1.17.20",
21
21
  "@types/jest": "^26.0.22",
@@ -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.4.7"
31
+ "@graphitation/supermassive-ast": "^2.0.0"
32
32
  },
33
33
  "sideEffects": false,
34
34
  "access": "public",