@graphitation/apollo-react-relay-duct-tape-compiler 1.2.4 → 1.3.1
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/CHANGELOG.md +19 -2
- package/lib/cli.js +17 -0
- package/lib/cli.js.map +2 -2
- package/lib/cli.mjs +17 -0
- package/lib/cli.mjs.map +2 -2
- package/lib/formatModule.d.ts +2 -0
- package/lib/formatModule.d.ts.map +1 -1
- package/lib/formatModule.js +30 -4
- package/lib/formatModule.js.map +2 -2
- package/lib/formatModule.mjs +30 -4
- package/lib/formatModule.mjs.map +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - @graphitation/apollo-react-relay-duct-tape-compiler
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 27 Sep 2023 14:33:43 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.3.1
|
|
8
|
+
|
|
9
|
+
Wed, 27 Sep 2023 14:33:43 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Fix transforms to actually do both v3 and v2 (mnovikov@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 1.3.0
|
|
16
|
+
|
|
17
|
+
Wed, 27 Sep 2023 08:50:33 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- Support supermassive v3 annotations (mnovikov@microsoft.com)
|
|
22
|
+
- Bump @graphitation/supermassive to v3.1.0
|
|
23
|
+
|
|
7
24
|
## 1.2.4
|
|
8
25
|
|
|
9
|
-
Thu, 21 Sep 2023 06:
|
|
26
|
+
Thu, 21 Sep 2023 06:28:45 GMT
|
|
10
27
|
|
|
11
28
|
### Patches
|
|
12
29
|
|
package/lib/cli.js
CHANGED
|
@@ -150,6 +150,23 @@ function main() {
|
|
|
150
150
|
demandOption: false,
|
|
151
151
|
default: false,
|
|
152
152
|
type: "boolean"
|
|
153
|
+
},
|
|
154
|
+
supermassiveDocumentNodeOutputType: {
|
|
155
|
+
demandOption: false,
|
|
156
|
+
default: "V2",
|
|
157
|
+
type: "string",
|
|
158
|
+
coerce: (value) => {
|
|
159
|
+
switch (value) {
|
|
160
|
+
case "V2":
|
|
161
|
+
return "V2";
|
|
162
|
+
case "V3":
|
|
163
|
+
return "V3";
|
|
164
|
+
case "BOTH":
|
|
165
|
+
return "BOTH";
|
|
166
|
+
default:
|
|
167
|
+
return "V2";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
153
170
|
}
|
|
154
171
|
}).help().argv;
|
|
155
172
|
if (!argv.emitDocuments) {
|
package/lib/cli.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cli.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\n/* istanbul ignore file */\n\nimport * as yargs from \"yargs\";\nimport { relayCompiler } from \"relay-compiler\";\nimport { pluginFactory } from \"./relayCompilerLanguagePlugin\";\n\n// TODO: This needs to be done here to ensure we get to mutate the transforms lists that get used.\nimport { IRTransforms } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { enableNodeWatchQueryTransform } from \"./compilerTransforms/enableNodeWatchQueryTransform\";\nimport { annotateFragmentReferenceTransform } from \"./compilerTransforms/annotateFragmentReferenceTransform\";\nimport { emitApolloClientConnectionTransform } from \"./compilerTransforms/emitApolloClientConnectionTransform\";\nimport { retainConnectionDirectiveTransform } from \"./compilerTransforms/retainConnectionDirectiveTransform\";\n\nfunction wrapTransform(\n transformName: string,\n transforms: IRTransform[],\n wrapperTransform: (wrappedTransform: IRTransform) => IRTransform,\n) {\n const transformIndex = transforms.findIndex(\n (transform) => transform.name === transformName,\n );\n const wrappedTransform = transforms[transformIndex];\n transforms[transformIndex] = wrapperTransform(wrappedTransform);\n}\n\nwrapTransform(\n \"filterDirectivesTransform\",\n IRTransforms.printTransforms,\n retainConnectionDirectiveTransform,\n);\nwrapTransform(\n \"connectionTransform\",\n IRTransforms.commonTransforms,\n emitApolloClientConnectionTransform,\n);\n\nasync function main() {\n const argv = await yargs\n .scriptName(\"duct-tape-compiler\")\n .options({\n src: {\n demandOption: false,\n default: \".\",\n type: \"string\",\n },\n exclude: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n include: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n schema: {\n demandOption: true,\n type: \"string\",\n },\n validate: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n verbose: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watch: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watchman: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n quiet: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitDocuments: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitNarrowObservables: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitQueryDebugComments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitSupermassiveDocuments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n })\n .help().argv;\n\n if (!argv.emitDocuments) {\n argv.emitNarrowObservables = false;\n argv.emitQueryDebugComments = false;\n }\n\n if (argv.emitNarrowObservables) {\n // TODO: Moving this up in the list might potentially optimize the query further\n IRTransforms.printTransforms.push(annotateFragmentReferenceTransform);\n IRTransforms.commonTransforms.unshift(enableNodeWatchQueryTransform);\n }\n\n const ductTapeCompilerLanguagePlugin = await pluginFactory(argv);\n\n return relayCompiler({\n ...argv,\n language: ductTapeCompilerLanguagePlugin,\n extensions: [\"ts\", \"tsx\"], // FIXME: Why is this not taken from the language plugin?\n include: argv.include || [\"**\"],\n exclude: [\n \"**/node_modules/**\",\n \"**/__mocks__/**\",\n \"**/__generated__/**\",\n // relay-compiler will treat these as client-side schema extensions\n \"**/*.graphql\",\n ...(argv.exclude || []),\n ],\n noFutureProofEnums: true,\n customScalars: {},\n });\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,YAAuB;AACvB,4BAA8B;AAC9B,yCAA8B;AAG9B,IAAAA,yBAA6B;AAE7B,2CAA8C;AAC9C,gDAAmD;AACnD,iDAAoD;AACpD,gDAAmD;AAEnD,SAAS,cACP,eACA,YACA,kBACA;AACA,QAAM,iBAAiB,WAAW;AAAA,IAChC,CAAC,cAAc,UAAU,SAAS;AAAA,EACpC;AACA,QAAM,mBAAmB,WAAW,cAAc;AAClD,aAAW,cAAc,IAAI,iBAAiB,gBAAgB;AAChE;AAEA;AAAA,EACE;AAAA,EACA,oCAAa;AAAA,EACb;AACF;AACA;AAAA,EACE;AAAA,EACA,oCAAa;AAAA,EACb;AACF;AAEA,SAAe,OAAO;AAAA;AACpB,UAAM,OAAO,MAAM,MAChB,WAAW,oBAAoB,EAC/B,QAAQ;AAAA,MACP,KAAK;AAAA,QACH,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACP,cAAc;AAAA,QACd,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,MACA,SAAS;AAAA,QACP,cAAc;AAAA,QACd,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,MACA,QAAQ;AAAA,QACN,cAAc;AAAA,QACd,MAAM;AAAA,MACR;AAAA,MACA,UAAU;AAAA,QACR,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACP,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,OAAO;AAAA,QACL,cAAc;A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
|
+
"sourcesContent": ["#!/usr/bin/env node\n\n/* istanbul ignore file */\n\nimport * as yargs from \"yargs\";\nimport { relayCompiler } from \"relay-compiler\";\nimport { pluginFactory } from \"./relayCompilerLanguagePlugin\";\n\n// TODO: This needs to be done here to ensure we get to mutate the transforms lists that get used.\nimport { IRTransforms } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { enableNodeWatchQueryTransform } from \"./compilerTransforms/enableNodeWatchQueryTransform\";\nimport { annotateFragmentReferenceTransform } from \"./compilerTransforms/annotateFragmentReferenceTransform\";\nimport { emitApolloClientConnectionTransform } from \"./compilerTransforms/emitApolloClientConnectionTransform\";\nimport { retainConnectionDirectiveTransform } from \"./compilerTransforms/retainConnectionDirectiveTransform\";\n\nfunction wrapTransform(\n transformName: string,\n transforms: IRTransform[],\n wrapperTransform: (wrappedTransform: IRTransform) => IRTransform,\n) {\n const transformIndex = transforms.findIndex(\n (transform) => transform.name === transformName,\n );\n const wrappedTransform = transforms[transformIndex];\n transforms[transformIndex] = wrapperTransform(wrappedTransform);\n}\n\nwrapTransform(\n \"filterDirectivesTransform\",\n IRTransforms.printTransforms,\n retainConnectionDirectiveTransform,\n);\nwrapTransform(\n \"connectionTransform\",\n IRTransforms.commonTransforms,\n emitApolloClientConnectionTransform,\n);\n\nasync function main() {\n const argv = await yargs\n .scriptName(\"duct-tape-compiler\")\n .options({\n src: {\n demandOption: false,\n default: \".\",\n type: \"string\",\n },\n exclude: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n include: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n schema: {\n demandOption: true,\n type: \"string\",\n },\n validate: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n verbose: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watch: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watchman: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n quiet: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitDocuments: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitNarrowObservables: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitQueryDebugComments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitSupermassiveDocuments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n supermassiveDocumentNodeOutputType: {\n demandOption: false,\n default: \"V2\",\n type: \"string\",\n coerce: (value) => {\n switch (value) {\n case \"V2\":\n return \"V2\";\n case \"V3\":\n return \"V3\";\n case \"BOTH\":\n return \"BOTH\";\n default:\n return \"V2\";\n }\n },\n },\n })\n .help().argv;\n\n if (!argv.emitDocuments) {\n argv.emitNarrowObservables = false;\n argv.emitQueryDebugComments = false;\n }\n\n if (argv.emitNarrowObservables) {\n // TODO: Moving this up in the list might potentially optimize the query further\n IRTransforms.printTransforms.push(annotateFragmentReferenceTransform);\n IRTransforms.commonTransforms.unshift(enableNodeWatchQueryTransform);\n }\n\n const ductTapeCompilerLanguagePlugin = await pluginFactory(argv);\n\n return relayCompiler({\n ...argv,\n language: ductTapeCompilerLanguagePlugin,\n extensions: [\"ts\", \"tsx\"], // FIXME: Why is this not taken from the language plugin?\n include: argv.include || [\"**\"],\n exclude: [\n \"**/node_modules/**\",\n \"**/__mocks__/**\",\n \"**/__generated__/**\",\n // relay-compiler will treat these as client-side schema extensions\n \"**/*.graphql\",\n ...(argv.exclude || []),\n ],\n noFutureProofEnums: true,\n customScalars: {},\n });\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,YAAuB;AACvB,4BAA8B;AAC9B,yCAA8B;AAG9B,IAAAA,yBAA6B;AAE7B,2CAA8C;AAC9C,gDAAmD;AACnD,iDAAoD;AACpD,gDAAmD;AAEnD,SAAS,cACP,eACA,YACA,kBACA;AACA,QA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AA,QACT,MAAM;AAAA,MACR;AAAA,MACA,2BAA2B;AAAA,QACzB,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,oCAAoC;AAAA,QAClC,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,QACN,QAAQ,CAAC,UAAU;AACjB,kBAAQ,OAAO;AAAA,YACb,KAAK;AACH,qBAAO;AAAA,YACT,KAAK;AACH,qBAAO;AAAA,YACT,KAAK;AACH,qBAAO;AAAA,YACT;AACE,qBAAO;AAAA,UACX;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,EACA,KAAK,EAAE;AAEV,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,wBAAwB;AAC7B,WAAK,yBAAyB;AAAA,IAChC;AAEA,QAAI,KAAK,uBAAuB;AAE9B,0CAAa,gBAAgB,KAAK,4EAAkC;AACpE,0CAAa,iBAAiB,QAAQ,kEAA6B;AAAA,IACrE;AAEA,UAAM,iCAAiC,UAAM,kDAAc,IAAI;AAE/D,eAAO,qCAAc,iCAChB,OADgB;AAAA,MAEnB,UAAU;AAAA,MACV,YAAY,CAAC,MAAM,KAAK;AAAA;AAAA,MACxB,SAAS,KAAK,WAAW,CAAC,IAAI;AAAA,MAC9B,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA;AAAA,QAEA;AAAA,QACA,GAAI,KAAK,WAAW,CAAC;AAAA,MACvB;AAAA,MACA,oBAAoB;AAAA,MACpB,eAAe,CAAC;AAAA,IAClB,EAAC;AAAA,EACH;AAAA;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB,CAAC;",
|
|
6
6
|
"names": ["import_relay_compiler"]
|
|
7
7
|
}
|
package/lib/cli.mjs
CHANGED
|
@@ -131,6 +131,23 @@ function main() {
|
|
|
131
131
|
demandOption: false,
|
|
132
132
|
default: false,
|
|
133
133
|
type: "boolean"
|
|
134
|
+
},
|
|
135
|
+
supermassiveDocumentNodeOutputType: {
|
|
136
|
+
demandOption: false,
|
|
137
|
+
default: "V2",
|
|
138
|
+
type: "string",
|
|
139
|
+
coerce: (value) => {
|
|
140
|
+
switch (value) {
|
|
141
|
+
case "V2":
|
|
142
|
+
return "V2";
|
|
143
|
+
case "V3":
|
|
144
|
+
return "V3";
|
|
145
|
+
case "BOTH":
|
|
146
|
+
return "BOTH";
|
|
147
|
+
default:
|
|
148
|
+
return "V2";
|
|
149
|
+
}
|
|
150
|
+
}
|
|
134
151
|
}
|
|
135
152
|
}).help().argv;
|
|
136
153
|
if (!argv.emitDocuments) {
|
package/lib/cli.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cli.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\n/* istanbul ignore file */\n\nimport * as yargs from \"yargs\";\nimport { relayCompiler } from \"relay-compiler\";\nimport { pluginFactory } from \"./relayCompilerLanguagePlugin\";\n\n// TODO: This needs to be done here to ensure we get to mutate the transforms lists that get used.\nimport { IRTransforms } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { enableNodeWatchQueryTransform } from \"./compilerTransforms/enableNodeWatchQueryTransform\";\nimport { annotateFragmentReferenceTransform } from \"./compilerTransforms/annotateFragmentReferenceTransform\";\nimport { emitApolloClientConnectionTransform } from \"./compilerTransforms/emitApolloClientConnectionTransform\";\nimport { retainConnectionDirectiveTransform } from \"./compilerTransforms/retainConnectionDirectiveTransform\";\n\nfunction wrapTransform(\n transformName: string,\n transforms: IRTransform[],\n wrapperTransform: (wrappedTransform: IRTransform) => IRTransform,\n) {\n const transformIndex = transforms.findIndex(\n (transform) => transform.name === transformName,\n );\n const wrappedTransform = transforms[transformIndex];\n transforms[transformIndex] = wrapperTransform(wrappedTransform);\n}\n\nwrapTransform(\n \"filterDirectivesTransform\",\n IRTransforms.printTransforms,\n retainConnectionDirectiveTransform,\n);\nwrapTransform(\n \"connectionTransform\",\n IRTransforms.commonTransforms,\n emitApolloClientConnectionTransform,\n);\n\nasync function main() {\n const argv = await yargs\n .scriptName(\"duct-tape-compiler\")\n .options({\n src: {\n demandOption: false,\n default: \".\",\n type: \"string\",\n },\n exclude: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n include: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n schema: {\n demandOption: true,\n type: \"string\",\n },\n validate: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n verbose: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watch: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watchman: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n quiet: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitDocuments: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitNarrowObservables: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitQueryDebugComments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitSupermassiveDocuments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n })\n .help().argv;\n\n if (!argv.emitDocuments) {\n argv.emitNarrowObservables = false;\n argv.emitQueryDebugComments = false;\n }\n\n if (argv.emitNarrowObservables) {\n // TODO: Moving this up in the list might potentially optimize the query further\n IRTransforms.printTransforms.push(annotateFragmentReferenceTransform);\n IRTransforms.commonTransforms.unshift(enableNodeWatchQueryTransform);\n }\n\n const ductTapeCompilerLanguagePlugin = await pluginFactory(argv);\n\n return relayCompiler({\n ...argv,\n language: ductTapeCompilerLanguagePlugin,\n extensions: [\"ts\", \"tsx\"], // FIXME: Why is this not taken from the language plugin?\n include: argv.include || [\"**\"],\n exclude: [\n \"**/node_modules/**\",\n \"**/__mocks__/**\",\n \"**/__generated__/**\",\n // relay-compiler will treat these as client-side schema extensions\n \"**/*.graphql\",\n ...(argv.exclude || []),\n ],\n noFutureProofEnums: true,\n customScalars: {},\n });\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,YAAY,WAAW;AACvB,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAG9B,SAAS,oBAAoB;AAE7B,SAAS,qCAAqC;AAC9C,SAAS,0CAA0C;AACnD,SAAS,2CAA2C;AACpD,SAAS,0CAA0C;AAEnD,SAAS,cACP,eACA,YACA,kBACA;AACA,QAAM,iBAAiB,WAAW;AAAA,IAChC,CAAC,cAAc,UAAU,SAAS;AAAA,EACpC;AACA,QAAM,mBAAmB,WAAW,cAAc;AAClD,aAAW,cAAc,IAAI,iBAAiB,gBAAgB;AAChE;AAEA;AAAA,EACE;AAAA,EACA,aAAa;AAAA,EACb;AACF;AACA;AAAA,EACE;AAAA,EACA,aAAa;AAAA,EACb;AACF;AAEA,SAAe,OAAO;AAAA;AACpB,UAAM,OAAO,MACV,iBAAW,oBAAoB,EAC/B,QAAQ;AAAA,MACP,KAAK;AAAA,QACH,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACP,cAAc;AAAA,QACd,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,MACA,SAAS;AAAA,QACP,cAAc;AAAA,QACd,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,MACA,QAAQ;AAAA,QACN,cAAc;AAAA,QACd,MAAM;AAAA,MACR;AAAA,MACA,UAAU;AAAA,QACR,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACP,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,OAAO;AAAA,QACL,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA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port * as yargs from \"yargs\";\nimport { relayCompiler } from \"relay-compiler\";\nimport { pluginFactory } from \"./relayCompilerLanguagePlugin\";\n\n// TODO: This needs to be done here to ensure we get to mutate the transforms lists that get used.\nimport { IRTransforms } from \"relay-compiler\";\nimport { IRTransform } from \"relay-compiler/lib/core/CompilerContext\";\nimport { enableNodeWatchQueryTransform } from \"./compilerTransforms/enableNodeWatchQueryTransform\";\nimport { annotateFragmentReferenceTransform } from \"./compilerTransforms/annotateFragmentReferenceTransform\";\nimport { emitApolloClientConnectionTransform } from \"./compilerTransforms/emitApolloClientConnectionTransform\";\nimport { retainConnectionDirectiveTransform } from \"./compilerTransforms/retainConnectionDirectiveTransform\";\n\nfunction wrapTransform(\n transformName: string,\n transforms: IRTransform[],\n wrapperTransform: (wrappedTransform: IRTransform) => IRTransform,\n) {\n const transformIndex = transforms.findIndex(\n (transform) => transform.name === transformName,\n );\n const wrappedTransform = transforms[transformIndex];\n transforms[transformIndex] = wrapperTransform(wrappedTransform);\n}\n\nwrapTransform(\n \"filterDirectivesTransform\",\n IRTransforms.printTransforms,\n retainConnectionDirectiveTransform,\n);\nwrapTransform(\n \"connectionTransform\",\n IRTransforms.commonTransforms,\n emitApolloClientConnectionTransform,\n);\n\nasync function main() {\n const argv = await yargs\n .scriptName(\"duct-tape-compiler\")\n .options({\n src: {\n demandOption: false,\n default: \".\",\n type: \"string\",\n },\n exclude: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n include: {\n demandOption: false,\n type: \"string\",\n array: true,\n },\n schema: {\n demandOption: true,\n type: \"string\",\n },\n validate: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n verbose: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watch: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n watchman: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n quiet: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitDocuments: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitNarrowObservables: {\n demandOption: false,\n default: true,\n type: \"boolean\",\n },\n emitQueryDebugComments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n emitSupermassiveDocuments: {\n demandOption: false,\n default: false,\n type: \"boolean\",\n },\n supermassiveDocumentNodeOutputType: {\n demandOption: false,\n default: \"V2\",\n type: \"string\",\n coerce: (value) => {\n switch (value) {\n case \"V2\":\n return \"V2\";\n case \"V3\":\n return \"V3\";\n case \"BOTH\":\n return \"BOTH\";\n default:\n return \"V2\";\n }\n },\n },\n })\n .help().argv;\n\n if (!argv.emitDocuments) {\n argv.emitNarrowObservables = false;\n argv.emitQueryDebugComments = false;\n }\n\n if (argv.emitNarrowObservables) {\n // TODO: Moving this up in the list might potentially optimize the query further\n IRTransforms.printTransforms.push(annotateFragmentReferenceTransform);\n IRTransforms.commonTransforms.unshift(enableNodeWatchQueryTransform);\n }\n\n const ductTapeCompilerLanguagePlugin = await pluginFactory(argv);\n\n return relayCompiler({\n ...argv,\n language: ductTapeCompilerLanguagePlugin,\n extensions: [\"ts\", \"tsx\"], // FIXME: Why is this not taken from the language plugin?\n include: argv.include || [\"**\"],\n exclude: [\n \"**/node_modules/**\",\n \"**/__mocks__/**\",\n \"**/__generated__/**\",\n // relay-compiler will treat these as client-side schema extensions\n \"**/*.graphql\",\n ...(argv.exclude || []),\n ],\n noFutureProofEnums: true,\n customScalars: {},\n });\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,YAAY,WAAW;AACvB,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAG9B,SAAS,oBAAoB;AAE7B,SAAS,qCAAqC;AAC9C,SAAS,0CAA0C;AACnD,SAAS,2CAA2C;AACpD,SAAS,0CAA0C;AAEnD,SAAS,cACP,eACA,YACA,kBACA;AACA,QAAM,iBAAiB,WAAW;AAAA,IAChC,CAAC,cA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AA,QACzB,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,oCAAoC;AAAA,QAClC,cAAc;AAAA,QACd,SAAS;AAAA,QACT,MAAM;AAAA,QACN,QAAQ,CAAC,UAAU;AACjB,kBAAQ,OAAO;AAAA,YACb,KAAK;AACH,qBAAO;AAAA,YACT,KAAK;AACH,qBAAO;AAAA,YACT,KAAK;AACH,qBAAO;AAAA,YACT;AACE,qBAAO;AAAA,UACX;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC,EACA,KAAK,EAAE;AAEV,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,wBAAwB;AAC7B,WAAK,yBAAyB;AAAA,IAChC;AAEA,QAAI,KAAK,uBAAuB;AAE9B,mBAAa,gBAAgB,KAAK,kCAAkC;AACpE,mBAAa,iBAAiB,QAAQ,6BAA6B;AAAA,IACrE;AAEA,UAAM,iCAAiC,MAAM,cAAc,IAAI;AAE/D,WAAO,cAAc,iCAChB,OADgB;AAAA,MAEnB,UAAU;AAAA,MACV,YAAY,CAAC,MAAM,KAAK;AAAA;AAAA,MACxB,SAAS,KAAK,WAAW,CAAC,IAAI;AAAA,MAC9B,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA;AAAA,QAEA;AAAA,QACA,GAAI,KAAK,WAAW,CAAC;AAAA,MACvB;AAAA,MACA,oBAAoB;AAAA,MACpB,eAAe,CAAC;AAAA,IAClB,EAAC;AAAA,EACH;AAAA;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/formatModule.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { FormatModule } from "relay-compiler/lib/language/RelayLanguagePluginInterface";
|
|
2
|
+
export type SupermassiveOutputType = "V3" | "V2" | "BOTH";
|
|
2
3
|
export interface FormatModuleOptions {
|
|
3
4
|
emitDocuments: boolean;
|
|
4
5
|
emitNarrowObservables: boolean;
|
|
5
6
|
emitQueryDebugComments: boolean;
|
|
6
7
|
emitSupermassiveDocuments: boolean;
|
|
8
|
+
supermassiveDocumentNodeOutputType: SupermassiveOutputType;
|
|
7
9
|
schema: string;
|
|
8
10
|
}
|
|
9
11
|
export declare function formatModuleFactory(options: FormatModuleOptions): Promise<FormatModule>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatModule.d.ts","sourceRoot":"","sources":["../src/formatModule.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AAI7F,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,sBAAsB,EAAE,OAAO,CAAC;IAChC,yBAAyB,EAAE,OAAO,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"formatModule.d.ts","sourceRoot":"","sources":["../src/formatModule.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AAI7F,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,OAAO,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,sBAAsB,EAAE,OAAO,CAAC;IAChC,yBAAyB,EAAE,OAAO,CAAC;IACnC,kCAAkC,EAAE,sBAAsB,CAAC;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CA+FvB"}
|
package/lib/formatModule.js
CHANGED
|
@@ -70,9 +70,13 @@ function formatModuleFactory(options) {
|
|
|
70
70
|
const schema = options.emitNarrowObservables || options.emitSupermassiveDocuments ? (0, import_graphql2.buildSchema)(
|
|
71
71
|
new import_graphql2.Source((0, import_fs.readFileSync)(options.schema, "utf-8"), options.schema)
|
|
72
72
|
) : null;
|
|
73
|
-
let
|
|
73
|
+
let addSupermassiveLegacyTypesToRequestDocument;
|
|
74
|
+
let addMinimalViableSchemaToRequestDocument;
|
|
74
75
|
if (options.emitSupermassiveDocuments) {
|
|
75
|
-
({
|
|
76
|
+
({
|
|
77
|
+
addSupermassiveLegacyTypesToRequestDocument,
|
|
78
|
+
addMinimalViableSchemaToRequestDocument
|
|
79
|
+
} = yield import("@graphitation/supermassive"));
|
|
76
80
|
}
|
|
77
81
|
function generateExports(moduleName, docText, emitNarrowObservables) {
|
|
78
82
|
const exports = {};
|
|
@@ -91,11 +95,14 @@ function formatModuleFactory(options) {
|
|
|
91
95
|
);
|
|
92
96
|
exports.metadata = (0, import_extractMetadataTransform.extractMetadataTransform)(exports.watchQueryDocument);
|
|
93
97
|
}
|
|
94
|
-
if (
|
|
98
|
+
if (options.emitSupermassiveDocuments && exports.executionQueryDocument) {
|
|
95
99
|
(0, import_invariant.default)(schema, "Expected a schema instance");
|
|
96
100
|
exports.executionQueryDocument = addTypesToRequestDocument(
|
|
97
101
|
schema,
|
|
98
|
-
exports.executionQueryDocument
|
|
102
|
+
exports.executionQueryDocument,
|
|
103
|
+
options.supermassiveDocumentNodeOutputType,
|
|
104
|
+
addMinimalViableSchemaToRequestDocument,
|
|
105
|
+
addSupermassiveLegacyTypesToRequestDocument
|
|
99
106
|
);
|
|
100
107
|
}
|
|
101
108
|
return exports;
|
|
@@ -147,3 +154,22 @@ function printExports(exports) {
|
|
|
147
154
|
|
|
148
155
|
export default documents;`;
|
|
149
156
|
}
|
|
157
|
+
function addTypesToRequestDocument(schema, document, supermassiveDocumentNodeOutputType, addMinimalViableSchemaToRequestDocument, addSupermassiveLegacyTypesToRequestDocument) {
|
|
158
|
+
let finalDocument = document;
|
|
159
|
+
if (supermassiveDocumentNodeOutputType === "V3" || supermassiveDocumentNodeOutputType === "BOTH") {
|
|
160
|
+
finalDocument = addMinimalViableSchemaToRequestDocument(
|
|
161
|
+
schema,
|
|
162
|
+
finalDocument,
|
|
163
|
+
{
|
|
164
|
+
addTo: "PROPERTY"
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
if (supermassiveDocumentNodeOutputType === "V2" || supermassiveDocumentNodeOutputType === "BOTH" || !supermassiveDocumentNodeOutputType) {
|
|
169
|
+
finalDocument = addSupermassiveLegacyTypesToRequestDocument(
|
|
170
|
+
schema,
|
|
171
|
+
finalDocument
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return finalDocument;
|
|
175
|
+
}
|
package/lib/formatModule.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/formatModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { parse, print } from \"graphql\";\nimport { optimizeDocumentNode } from \"@graphql-tools/optimize\";\nimport { reduceNodeWatchQueryTransform } from \"./formatModuleTransforms/reduceNodeWatchQueryTransform\";\nimport invariant from \"invariant\";\nimport { stripFragmentReferenceFieldSelectionTransform } from \"./formatModuleTransforms/stripFragmentReferenceFieldSelectionTransform\";\nimport { extractMetadataTransform } from \"./formatModuleTransforms/extractMetadataTransform\";\nimport { buildSchema, Source } from \"graphql\";\nimport { readFileSync } from \"fs\";\nimport dedupeJSONStringify from \"relay-compiler/lib/util/dedupeJSONStringify\";\n\nimport type { DocumentNode } from \"graphql\";\nimport type { FormatModule } from \"relay-compiler/lib/language/RelayLanguagePluginInterface\";\nimport type { CompiledArtefactModule } from \"./types\";\nimport { Fragment } from \"relay-compiler\";\n\nexport interface FormatModuleOptions {\n emitDocuments: boolean;\n emitNarrowObservables: boolean;\n emitQueryDebugComments: boolean;\n emitSupermassiveDocuments: boolean;\n schema: string;\n}\n\nfunction printDocumentComment(document: DocumentNode) {\n return `/*\\n${print(document).trim()}\\n*/`;\n}\n\nexport async function formatModuleFactory(\n options: FormatModuleOptions,\n): Promise<FormatModule> {\n const schema =\n options.emitNarrowObservables || options.emitSupermassiveDocuments\n ? buildSchema(\n new Source(readFileSync(options.schema, \"utf-8\"), options.schema),\n )\n : null;\n\n let
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,sBAAqC;AACrC,2CAA8C;AAC9C,uBAAsB;AACtB,2DAA8D;AAC9D,sCAAyC;AACzC,IAAAA,kBAAoC;AACpC,gBAA6B;AAC7B,iCAAgC;
|
|
4
|
+
"sourcesContent": ["import { parse, print } from \"graphql\";\nimport { optimizeDocumentNode } from \"@graphql-tools/optimize\";\nimport { reduceNodeWatchQueryTransform } from \"./formatModuleTransforms/reduceNodeWatchQueryTransform\";\nimport invariant from \"invariant\";\nimport { stripFragmentReferenceFieldSelectionTransform } from \"./formatModuleTransforms/stripFragmentReferenceFieldSelectionTransform\";\nimport { extractMetadataTransform } from \"./formatModuleTransforms/extractMetadataTransform\";\nimport { buildSchema, Source } from \"graphql\";\nimport { readFileSync } from \"fs\";\nimport dedupeJSONStringify from \"relay-compiler/lib/util/dedupeJSONStringify\";\n\nimport type { DocumentNode, GraphQLSchema } from \"graphql\";\nimport type { FormatModule } from \"relay-compiler/lib/language/RelayLanguagePluginInterface\";\nimport type { CompiledArtefactModule } from \"./types\";\nimport { Fragment } from \"relay-compiler\";\n\nexport type SupermassiveOutputType = \"V3\" | \"V2\" | \"BOTH\";\n\nexport interface FormatModuleOptions {\n emitDocuments: boolean;\n emitNarrowObservables: boolean;\n emitQueryDebugComments: boolean;\n emitSupermassiveDocuments: boolean;\n supermassiveDocumentNodeOutputType: SupermassiveOutputType;\n schema: string;\n}\n\nfunction printDocumentComment(document: DocumentNode) {\n return `/*\\n${print(document).trim()}\\n*/`;\n}\n\nexport async function formatModuleFactory(\n options: FormatModuleOptions,\n): Promise<FormatModule> {\n const schema =\n options.emitNarrowObservables || options.emitSupermassiveDocuments\n ? buildSchema(\n new Source(readFileSync(options.schema, \"utf-8\"), options.schema),\n )\n : null;\n\n let addSupermassiveLegacyTypesToRequestDocument:\n | undefined\n | typeof import(\"@graphitation/supermassive\").addSupermassiveLegacyTypesToRequestDocument;\n let addMinimalViableSchemaToRequestDocument:\n | undefined\n | typeof import(\"@graphitation/supermassive\").addMinimalViableSchemaToRequestDocument;\n if (options.emitSupermassiveDocuments) {\n ({\n addSupermassiveLegacyTypesToRequestDocument,\n addMinimalViableSchemaToRequestDocument,\n } = await import(\"@graphitation/supermassive\"));\n }\n\n function generateExports(\n moduleName: string,\n docText: string,\n emitNarrowObservables: boolean,\n ) {\n const exports: CompiledArtefactModule = {};\n const originalDocument = parse(docText, { noLocation: true });\n const optimizedDocument = optimizeDocumentNode(originalDocument);\n\n if (!emitNarrowObservables) {\n exports.executionQueryDocument = optimizedDocument;\n } else {\n if (!moduleName.endsWith(\"WatchNodeQuery.graphql\")) {\n exports.executionQueryDocument =\n stripFragmentReferenceFieldSelectionTransform(optimizedDocument);\n }\n\n invariant(schema, \"Expected a schema instance\");\n exports.watchQueryDocument = reduceNodeWatchQueryTransform(\n schema,\n optimizedDocument,\n );\n\n exports.metadata = extractMetadataTransform(exports.watchQueryDocument);\n }\n\n if (options.emitSupermassiveDocuments && exports.executionQueryDocument) {\n invariant(schema, \"Expected a schema instance\");\n exports.executionQueryDocument = addTypesToRequestDocument(\n schema,\n exports.executionQueryDocument,\n options.supermassiveDocumentNodeOutputType,\n addMinimalViableSchemaToRequestDocument,\n addSupermassiveLegacyTypesToRequestDocument,\n ) as DocumentNode;\n }\n\n return exports;\n }\n\n return ({ docText, hash, moduleName, typeText, definition }) => {\n const exports = options.emitDocuments\n ? docText &&\n generateExports(\n moduleName,\n docText,\n options.emitNarrowObservables &&\n definition.kind === \"Request\" &&\n definition.root.operation === \"query\",\n )\n : null;\n const reExportWatchNodeQuery =\n options.emitDocuments && definition.kind === \"Fragment\";\n\n const components = [\n typeText,\n exports &&\n options.emitQueryDebugComments &&\n exports.executionQueryDocument &&\n printDocumentComment(exports.executionQueryDocument),\n exports &&\n options.emitQueryDebugComments &&\n exports.watchQueryDocument &&\n printDocumentComment(exports.watchQueryDocument),\n exports && printExports(exports),\n reExportWatchNodeQuery && printWatchNodeQueryReExport(definition),\n ].filter(Boolean) as string[];\n\n return `/* tslint:disable */\n/* eslint-disable */\n// @ts-nocheck\n${hash ? `/* ${hash} */\\n` : \"\"}\n${components.join(\"\\n\\n\")}`;\n };\n}\n\n// TODO: hould simply not emit a WatchNodeQuery refetchable directive when there already is a @refetchable directive\nfunction printWatchNodeQueryReExport(definition: Fragment) {\n const refetchable =\n definition.directives.find(\n (d) => d.name === \"refetchable\" && d.loc.kind === \"Source\",\n ) ||\n definition.directives.find(\n (d) => d.name === \"refetchable\" && d.loc.kind === \"Generated\",\n );\n if (!refetchable) {\n return undefined;\n }\n const queryNameArg = refetchable.args[0];\n invariant(\n queryNameArg.name === \"queryName\" && queryNameArg.value.kind === \"Literal\",\n \"Expected a @refetchable(queryName:) argument\",\n );\n\n return `import { documents } from \"./${queryNameArg.value.value}.graphql\";\\nexport default documents;`;\n}\n\nfunction printExports(exports: CompiledArtefactModule) {\n return `export const documents: import(\"@graphitation/apollo-react-relay-duct-tape-compiler\").CompiledArtefactModule = ${dedupeJSONStringify(\n exports,\n )};\\n\\nexport default documents;`;\n}\n\nfunction addTypesToRequestDocument(\n schema: GraphQLSchema,\n document: DocumentNode,\n supermassiveDocumentNodeOutputType: SupermassiveOutputType,\n addMinimalViableSchemaToRequestDocument: any,\n addSupermassiveLegacyTypesToRequestDocument: any,\n) {\n let finalDocument = document;\n if (\n supermassiveDocumentNodeOutputType === \"V3\" ||\n supermassiveDocumentNodeOutputType === \"BOTH\"\n ) {\n finalDocument = addMinimalViableSchemaToRequestDocument(\n schema,\n finalDocument,\n {\n addTo: \"PROPERTY\",\n },\n );\n }\n\n if (\n supermassiveDocumentNodeOutputType === \"V2\" ||\n supermassiveDocumentNodeOutputType === \"BOTH\" ||\n !supermassiveDocumentNodeOutputType\n ) {\n finalDocument = addSupermassiveLegacyTypesToRequestDocument(\n schema,\n finalDocument,\n ) as unknown as DocumentNode;\n }\n return finalDocument;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,sBAAqC;AACrC,2CAA8C;AAC9C,uBAAsB;AACtB,2DAA8D;AAC9D,sCAAyC;AACzC,IAAAA,kBAAoC;AACpC,gBAA6B;AAC7B,iCAAgC;AAkBhC,SAAS,qBAAqB,UAAwB;AACpD,SAAO;AAAA,MAAO,sBAAM,QAAQ,EAAE,KAAK;AAAA;AACrC;AAEA,SAAsB,oBACpB,SACuB;AAAA;AACvB,UAAM,SACJ,QAAQ,yBAAyB,QAAQ,gCACrC;AAAA,MACE,IAAI,2BAAO,wBAAa,QAAQ,QAAQ,OAAO,GAAG,QAAQ,MAAM;AAAA,IAClE,IACA;AAEN,QAAI;AAGJ,QAAI;AAGJ,QAAI,QAAQ,2BAA2B;AACrC,OAAC;AAAA,QACC;AAAA,QACA;AAAA,MACF,IAAI,MAAM,OAAO,4BAA4B;AAAA,IAC/C;AAEA,aAAS,gBACP,YACA,SACA,uBACA;AACA,YAAM,UAAkC,CAAC;AACzC,YAAM,uBAAmB,sBAAM,SAAS,EAAE,YAAY,KAAK,CAAC;AAC5D,YAAM,wBAAoB,sCAAqB,gBAAgB;AAE/D,UAAI,CAAC,uBAAuB;AAC1B,gBAAQ,yBAAyB;AAAA,MACnC,OAAO;AACL,YAAI,CAAC,WAAW,SAAS,wBAAwB,GAAG;AAClD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iB,EAAE,IAAI,SAAS;AAAA,EACpD;AACF,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AACA,QAAM,eAAe,YAAY,KAAK,CAAC;AACvC,uBAAAA;AAAA,IACE,aAAa,SAAS,eAAe,aAAa,MAAM,SAAS;AAAA,IACjE;AAAA,EACF;AAEA,SAAO,gCAAgC,aAAa,MAAM;AAAA;AAC5D;AAEA,SAAS,aAAa,SAAiC;AACrD,SAAO,sHAAkH,2BAAAC;AAAA,IACvH;AAAA,EACF;AAAA;AAAA;AACF;AAEA,SAAS,0BACP,QACA,UACA,oCACA,yCACA,6CACA;AACA,MAAI,gBAAgB;AACpB,MACE,uCAAuC,QACvC,uCAAuC,QACvC;AACA,oBAAgB;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,MACE,uCAAuC,QACvC,uCAAuC,UACvC,CAAC,oCACD;AACA,oBAAgB;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["import_graphql", "invariant", "dedupeJSONStringify"]
|
|
7
7
|
}
|
package/lib/formatModule.mjs
CHANGED
|
@@ -39,9 +39,13 @@ function formatModuleFactory(options) {
|
|
|
39
39
|
const schema = options.emitNarrowObservables || options.emitSupermassiveDocuments ? buildSchema(
|
|
40
40
|
new Source(readFileSync(options.schema, "utf-8"), options.schema)
|
|
41
41
|
) : null;
|
|
42
|
-
let
|
|
42
|
+
let addSupermassiveLegacyTypesToRequestDocument;
|
|
43
|
+
let addMinimalViableSchemaToRequestDocument;
|
|
43
44
|
if (options.emitSupermassiveDocuments) {
|
|
44
|
-
({
|
|
45
|
+
({
|
|
46
|
+
addSupermassiveLegacyTypesToRequestDocument,
|
|
47
|
+
addMinimalViableSchemaToRequestDocument
|
|
48
|
+
} = yield import("@graphitation/supermassive"));
|
|
45
49
|
}
|
|
46
50
|
function generateExports(moduleName, docText, emitNarrowObservables) {
|
|
47
51
|
const exports = {};
|
|
@@ -60,11 +64,14 @@ function formatModuleFactory(options) {
|
|
|
60
64
|
);
|
|
61
65
|
exports.metadata = extractMetadataTransform(exports.watchQueryDocument);
|
|
62
66
|
}
|
|
63
|
-
if (
|
|
67
|
+
if (options.emitSupermassiveDocuments && exports.executionQueryDocument) {
|
|
64
68
|
invariant(schema, "Expected a schema instance");
|
|
65
69
|
exports.executionQueryDocument = addTypesToRequestDocument(
|
|
66
70
|
schema,
|
|
67
|
-
exports.executionQueryDocument
|
|
71
|
+
exports.executionQueryDocument,
|
|
72
|
+
options.supermassiveDocumentNodeOutputType,
|
|
73
|
+
addMinimalViableSchemaToRequestDocument,
|
|
74
|
+
addSupermassiveLegacyTypesToRequestDocument
|
|
68
75
|
);
|
|
69
76
|
}
|
|
70
77
|
return exports;
|
|
@@ -116,6 +123,25 @@ function printExports(exports) {
|
|
|
116
123
|
|
|
117
124
|
export default documents;`;
|
|
118
125
|
}
|
|
126
|
+
function addTypesToRequestDocument(schema, document, supermassiveDocumentNodeOutputType, addMinimalViableSchemaToRequestDocument, addSupermassiveLegacyTypesToRequestDocument) {
|
|
127
|
+
let finalDocument = document;
|
|
128
|
+
if (supermassiveDocumentNodeOutputType === "V3" || supermassiveDocumentNodeOutputType === "BOTH") {
|
|
129
|
+
finalDocument = addMinimalViableSchemaToRequestDocument(
|
|
130
|
+
schema,
|
|
131
|
+
finalDocument,
|
|
132
|
+
{
|
|
133
|
+
addTo: "PROPERTY"
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
if (supermassiveDocumentNodeOutputType === "V2" || supermassiveDocumentNodeOutputType === "BOTH" || !supermassiveDocumentNodeOutputType) {
|
|
138
|
+
finalDocument = addSupermassiveLegacyTypesToRequestDocument(
|
|
139
|
+
schema,
|
|
140
|
+
finalDocument
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
return finalDocument;
|
|
144
|
+
}
|
|
119
145
|
export {
|
|
120
146
|
formatModuleFactory
|
|
121
147
|
};
|
package/lib/formatModule.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/formatModule.ts"],
|
|
4
|
-
"sourcesContent": ["import { parse, print } from \"graphql\";\nimport { optimizeDocumentNode } from \"@graphql-tools/optimize\";\nimport { reduceNodeWatchQueryTransform } from \"./formatModuleTransforms/reduceNodeWatchQueryTransform\";\nimport invariant from \"invariant\";\nimport { stripFragmentReferenceFieldSelectionTransform } from \"./formatModuleTransforms/stripFragmentReferenceFieldSelectionTransform\";\nimport { extractMetadataTransform } from \"./formatModuleTransforms/extractMetadataTransform\";\nimport { buildSchema, Source } from \"graphql\";\nimport { readFileSync } from \"fs\";\nimport dedupeJSONStringify from \"relay-compiler/lib/util/dedupeJSONStringify\";\n\nimport type { DocumentNode } from \"graphql\";\nimport type { FormatModule } from \"relay-compiler/lib/language/RelayLanguagePluginInterface\";\nimport type { CompiledArtefactModule } from \"./types\";\nimport { Fragment } from \"relay-compiler\";\n\nexport interface FormatModuleOptions {\n emitDocuments: boolean;\n emitNarrowObservables: boolean;\n emitQueryDebugComments: boolean;\n emitSupermassiveDocuments: boolean;\n schema: string;\n}\n\nfunction printDocumentComment(document: DocumentNode) {\n return `/*\\n${print(document).trim()}\\n*/`;\n}\n\nexport async function formatModuleFactory(\n options: FormatModuleOptions,\n): Promise<FormatModule> {\n const schema =\n options.emitNarrowObservables || options.emitSupermassiveDocuments\n ? buildSchema(\n new Source(readFileSync(options.schema, \"utf-8\"), options.schema),\n )\n : null;\n\n let
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,aAAa;AAC7B,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAC9C,OAAO,eAAe;AACtB,SAAS,qDAAqD;AAC9D,SAAS,gCAAgC;AACzC,SAAS,aAAa,cAAc;AACpC,SAAS,oBAAoB;AAC7B,OAAO,yBAAyB;
|
|
4
|
+
"sourcesContent": ["import { parse, print } from \"graphql\";\nimport { optimizeDocumentNode } from \"@graphql-tools/optimize\";\nimport { reduceNodeWatchQueryTransform } from \"./formatModuleTransforms/reduceNodeWatchQueryTransform\";\nimport invariant from \"invariant\";\nimport { stripFragmentReferenceFieldSelectionTransform } from \"./formatModuleTransforms/stripFragmentReferenceFieldSelectionTransform\";\nimport { extractMetadataTransform } from \"./formatModuleTransforms/extractMetadataTransform\";\nimport { buildSchema, Source } from \"graphql\";\nimport { readFileSync } from \"fs\";\nimport dedupeJSONStringify from \"relay-compiler/lib/util/dedupeJSONStringify\";\n\nimport type { DocumentNode, GraphQLSchema } from \"graphql\";\nimport type { FormatModule } from \"relay-compiler/lib/language/RelayLanguagePluginInterface\";\nimport type { CompiledArtefactModule } from \"./types\";\nimport { Fragment } from \"relay-compiler\";\n\nexport type SupermassiveOutputType = \"V3\" | \"V2\" | \"BOTH\";\n\nexport interface FormatModuleOptions {\n emitDocuments: boolean;\n emitNarrowObservables: boolean;\n emitQueryDebugComments: boolean;\n emitSupermassiveDocuments: boolean;\n supermassiveDocumentNodeOutputType: SupermassiveOutputType;\n schema: string;\n}\n\nfunction printDocumentComment(document: DocumentNode) {\n return `/*\\n${print(document).trim()}\\n*/`;\n}\n\nexport async function formatModuleFactory(\n options: FormatModuleOptions,\n): Promise<FormatModule> {\n const schema =\n options.emitNarrowObservables || options.emitSupermassiveDocuments\n ? buildSchema(\n new Source(readFileSync(options.schema, \"utf-8\"), options.schema),\n )\n : null;\n\n let addSupermassiveLegacyTypesToRequestDocument:\n | undefined\n | typeof import(\"@graphitation/supermassive\").addSupermassiveLegacyTypesToRequestDocument;\n let addMinimalViableSchemaToRequestDocument:\n | undefined\n | typeof import(\"@graphitation/supermassive\").addMinimalViableSchemaToRequestDocument;\n if (options.emitSupermassiveDocuments) {\n ({\n addSupermassiveLegacyTypesToRequestDocument,\n addMinimalViableSchemaToRequestDocument,\n } = await import(\"@graphitation/supermassive\"));\n }\n\n function generateExports(\n moduleName: string,\n docText: string,\n emitNarrowObservables: boolean,\n ) {\n const exports: CompiledArtefactModule = {};\n const originalDocument = parse(docText, { noLocation: true });\n const optimizedDocument = optimizeDocumentNode(originalDocument);\n\n if (!emitNarrowObservables) {\n exports.executionQueryDocument = optimizedDocument;\n } else {\n if (!moduleName.endsWith(\"WatchNodeQuery.graphql\")) {\n exports.executionQueryDocument =\n stripFragmentReferenceFieldSelectionTransform(optimizedDocument);\n }\n\n invariant(schema, \"Expected a schema instance\");\n exports.watchQueryDocument = reduceNodeWatchQueryTransform(\n schema,\n optimizedDocument,\n );\n\n exports.metadata = extractMetadataTransform(exports.watchQueryDocument);\n }\n\n if (options.emitSupermassiveDocuments && exports.executionQueryDocument) {\n invariant(schema, \"Expected a schema instance\");\n exports.executionQueryDocument = addTypesToRequestDocument(\n schema,\n exports.executionQueryDocument,\n options.supermassiveDocumentNodeOutputType,\n addMinimalViableSchemaToRequestDocument,\n addSupermassiveLegacyTypesToRequestDocument,\n ) as DocumentNode;\n }\n\n return exports;\n }\n\n return ({ docText, hash, moduleName, typeText, definition }) => {\n const exports = options.emitDocuments\n ? docText &&\n generateExports(\n moduleName,\n docText,\n options.emitNarrowObservables &&\n definition.kind === \"Request\" &&\n definition.root.operation === \"query\",\n )\n : null;\n const reExportWatchNodeQuery =\n options.emitDocuments && definition.kind === \"Fragment\";\n\n const components = [\n typeText,\n exports &&\n options.emitQueryDebugComments &&\n exports.executionQueryDocument &&\n printDocumentComment(exports.executionQueryDocument),\n exports &&\n options.emitQueryDebugComments &&\n exports.watchQueryDocument &&\n printDocumentComment(exports.watchQueryDocument),\n exports && printExports(exports),\n reExportWatchNodeQuery && printWatchNodeQueryReExport(definition),\n ].filter(Boolean) as string[];\n\n return `/* tslint:disable */\n/* eslint-disable */\n// @ts-nocheck\n${hash ? `/* ${hash} */\\n` : \"\"}\n${components.join(\"\\n\\n\")}`;\n };\n}\n\n// TODO: hould simply not emit a WatchNodeQuery refetchable directive when there already is a @refetchable directive\nfunction printWatchNodeQueryReExport(definition: Fragment) {\n const refetchable =\n definition.directives.find(\n (d) => d.name === \"refetchable\" && d.loc.kind === \"Source\",\n ) ||\n definition.directives.find(\n (d) => d.name === \"refetchable\" && d.loc.kind === \"Generated\",\n );\n if (!refetchable) {\n return undefined;\n }\n const queryNameArg = refetchable.args[0];\n invariant(\n queryNameArg.name === \"queryName\" && queryNameArg.value.kind === \"Literal\",\n \"Expected a @refetchable(queryName:) argument\",\n );\n\n return `import { documents } from \"./${queryNameArg.value.value}.graphql\";\\nexport default documents;`;\n}\n\nfunction printExports(exports: CompiledArtefactModule) {\n return `export const documents: import(\"@graphitation/apollo-react-relay-duct-tape-compiler\").CompiledArtefactModule = ${dedupeJSONStringify(\n exports,\n )};\\n\\nexport default documents;`;\n}\n\nfunction addTypesToRequestDocument(\n schema: GraphQLSchema,\n document: DocumentNode,\n supermassiveDocumentNodeOutputType: SupermassiveOutputType,\n addMinimalViableSchemaToRequestDocument: any,\n addSupermassiveLegacyTypesToRequestDocument: any,\n) {\n let finalDocument = document;\n if (\n supermassiveDocumentNodeOutputType === \"V3\" ||\n supermassiveDocumentNodeOutputType === \"BOTH\"\n ) {\n finalDocument = addMinimalViableSchemaToRequestDocument(\n schema,\n finalDocument,\n {\n addTo: \"PROPERTY\",\n },\n );\n }\n\n if (\n supermassiveDocumentNodeOutputType === \"V2\" ||\n supermassiveDocumentNodeOutputType === \"BOTH\" ||\n !supermassiveDocumentNodeOutputType\n ) {\n finalDocument = addSupermassiveLegacyTypesToRequestDocument(\n schema,\n finalDocument,\n ) as unknown as DocumentNode;\n }\n return finalDocument;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,aAAa;AAC7B,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAC9C,OAAO,eAAe;AACtB,SAAS,qDAAqD;AAC9D,SAAS,gCAAgC;AACzC,SAAS,aAAa,cAAc;AACp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ACvC,uCAAuC,UACvC,CAAC,oCACD;AACA,oBAAgB;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphitation/apollo-react-relay-duct-tape-compiler",
|
|
3
3
|
"description": "The build tools to cater to @graphitation/apollo-react-relay-duct-tape's needs.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.3.1",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"duct-tape-compiler": "./lib/cli.js"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"graphql": "^15.0.0",
|
|
44
|
-
"@graphitation/supermassive
|
|
44
|
+
"@graphitation/supermassive": "^3.1.0",
|
|
45
45
|
"typescript": "^4.3.5"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|