@graphitation/apollo-react-relay-duct-tape-compiler 1.7.10 → 1.8.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/CHANGELOG.md +10 -2
- package/lib/cli.js +5 -0
- package/lib/cli.js.map +2 -2
- package/lib/cli.mjs +5 -0
- package/lib/cli.mjs.map +2 -2
- package/lib/formatModule.d.ts +1 -0
- package/lib/formatModule.d.ts.map +1 -1
- package/lib/formatModule.js +10 -2
- package/lib/formatModule.js.map +2 -2
- package/lib/formatModule.mjs +10 -2
- package/lib/formatModule.mjs.map +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
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 Mon, 18 Aug 2025 17:22:45 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.8.0
|
|
8
|
+
|
|
9
|
+
Mon, 18 Aug 2025 17:22:45 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- feat(apollo-react-relay-duct-tape-compiler): emit operation text for build-time analysis (vrazuvaev@microsoft.com_msteamsmdb)
|
|
14
|
+
|
|
7
15
|
## 1.7.10
|
|
8
16
|
|
|
9
|
-
Thu, 14 Aug 2025 10:
|
|
17
|
+
Thu, 14 Aug 2025 10:10:19 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/lib/cli.js
CHANGED
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 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,QAAM,iBAAiB,WAAW;AAAA,IAChC,CAAC,cAAc,UAAU,SAAS;AAAA,EACpC;AACA,QAAM,mBAAmB,WAAW,cAAc;AAClD,aAAW,cAAc,IAAI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AAAA,MAClC,cAAc;AAAA,MACd,SAAS;AAAA,MACT,MAAM;AAAA,MACN,QAAQ,CAAC,UAAU;AACjB,gBAAQ,OAAO;AAAA,UACb,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT;AACE,mBAAO;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC,EACA,KAAK,EAAE;AAEV,MAAI,CAAC,KAAK,eAAe;AACvB,SAAK,wBAAwB;AAC7B,SAAK,yBAAyB;AAAA,EAChC;AAEA,MAAI,KAAK,uBAAuB;AAE9B,wCAAa,gBAAgB,KAAK,4EAAkC;AACpE,wCAAa,iBAAiB,QAAQ,kEAA6B;AAAA,EACrE;AAEA,QAAM,iCAAiC,UAAM,kDAAc,IAAI;AAE/D,aAAO,qCAAc;AAAA,IACnB,GAAG;AAAA,IACH,UAAU;AAAA,IACV,YAAY,CAAC,MAAM,KAAK;AAAA;AAAA,IACxB,SAAS,KAAK,WAAW,CAAC,IAAI;AAAA,IAC9B,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAI,KAAK,WAAW,CAAC;AAAA,IACvB;AAAA,IACA,oBAAoB;AAAA,IACpB,eAAe,CAAC;AAAA,EAClB,CAAC;AACH;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB,CAAC;",
|
|
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 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 unstable_emitExecutionDocumentText: {\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,eAAe,OAAO;AACpB,QAAM,O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AAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT;AACE,mBAAO;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,IACA,oCAAoC;AAAA,MAClC,cAAc;AAAA,MACd,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF,CAAC,EACA,KAAK,EAAE;AAEV,MAAI,CAAC,KAAK,eAAe;AACvB,SAAK,wBAAwB;AAC7B,SAAK,yBAAyB;AAAA,EAChC;AAEA,MAAI,KAAK,uBAAuB;AAE9B,wCAAa,gBAAgB,KAAK,4EAAkC;AACpE,wCAAa,iBAAiB,QAAQ,kEAA6B;AAAA,EACrE;AAEA,QAAM,iCAAiC,UAAM,kDAAc,IAAI;AAE/D,aAAO,qCAAc;AAAA,IACnB,GAAG;AAAA,IACH,UAAU;AAAA,IACV,YAAY,CAAC,MAAM,KAAK;AAAA;AAAA,IACxB,SAAS,KAAK,WAAW,CAAC,IAAI;AAAA,IAC9B,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAI,KAAK,WAAW,CAAC;AAAA,IACvB;AAAA,IACA,oBAAoB;AAAA,IACpB,eAAe,CAAC;AAAA,EAClB,CAAC;AACH;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
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 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,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,EAC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,OAAO;AAAA,UACb,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT;AACE,mBAAO;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC,EACA,KAAK,EAAE;AAEV,MAAI,CAAC,KAAK,eAAe;AACvB,SAAK,wBAAwB;AAC7B,SAAK,yBAAyB;AAAA,EAChC;AAEA,MAAI,KAAK,uBAAuB;AAE9B,iBAAa,gBAAgB,KAAK,kCAAkC;AACpE,iBAAa,iBAAiB,QAAQ,6BAA6B;AAAA,EACrE;AAEA,QAAM,iCAAiC,MAAM,cAAc,IAAI;AAE/D,SAAO,cAAc;AAAA,IACnB,GAAG;AAAA,IACH,UAAU;AAAA,IACV,YAAY,CAAC,MAAM,KAAK;AAAA;AAAA,IACxB,SAAS,KAAK,WAAW,CAAC,IAAI;AAAA,IAC9B,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAI,KAAK,WAAW,CAAC;AAAA,IACvB;AAAA,IACA,oBAAoB;AAAA,IACpB,eAAe,CAAC;AAAA,EAClB,CAAC;AACH;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB,CAAC;",
|
|
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 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 unstable_emitExecutionDocumentText: {\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,eAAe,OAAO;AACpB,QAAM,OAAO,MACV,iBAAW,oBAAoB,EAC/B,QAAQ;AAAA,IACP,KAAK;AAAA,MACH,cAAc;AAAA,MACd,S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AA,IACA,oCAAoC;AAAA,MAClC,cAAc;AAAA,MACd,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF,CAAC,EACA,KAAK,EAAE;AAEV,MAAI,CAAC,KAAK,eAAe;AACvB,SAAK,wBAAwB;AAC7B,SAAK,yBAAyB;AAAA,EAChC;AAEA,MAAI,KAAK,uBAAuB;AAE9B,iBAAa,gBAAgB,KAAK,kCAAkC;AACpE,iBAAa,iBAAiB,QAAQ,6BAA6B;AAAA,EACrE;AAEA,QAAM,iCAAiC,MAAM,cAAc,IAAI;AAE/D,SAAO,cAAc;AAAA,IACnB,GAAG;AAAA,IACH,UAAU;AAAA,IACV,YAAY,CAAC,MAAM,KAAK;AAAA;AAAA,IACxB,SAAS,KAAK,WAAW,CAAC,IAAI;AAAA,IAC9B,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAI,KAAK,WAAW,CAAC;AAAA,IACvB;AAAA,IACA,oBAAoB;AAAA,IACpB,eAAe,CAAC;AAAA,EAClB,CAAC;AACH;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
|
@@ -7,6 +7,7 @@ export interface FormatModuleOptions {
|
|
|
7
7
|
emitSupermassiveDocuments: boolean;
|
|
8
8
|
supermassiveDocumentNodeOutputType: SupermassiveOutputType;
|
|
9
9
|
schema: string;
|
|
10
|
+
unstable_emitExecutionDocumentText: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare function formatModuleFactory(options: FormatModuleOptions): Promise<FormatModule>;
|
|
12
13
|
//# sourceMappingURL=formatModule.d.ts.map
|
|
@@ -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,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;
|
|
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;IACf,kCAAkC,EAAE,OAAO,CAAC;CAC7C;AAaD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CAqGvB"}
|
package/lib/formatModule.js
CHANGED
|
@@ -45,6 +45,12 @@ function printDocumentComment(document) {
|
|
|
45
45
|
${(0, import_graphql.print)(document).trim()}
|
|
46
46
|
*/`;
|
|
47
47
|
}
|
|
48
|
+
function printDocument(document) {
|
|
49
|
+
return `
|
|
50
|
+
// Note: executionDocumentText is necessary for Lazy AST and build-time operations analysis
|
|
51
|
+
const executionDocumentText = \`${(0, import_graphql.print)(document).trim()}\`;
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
48
54
|
async function formatModuleFactory(options) {
|
|
49
55
|
const schema = options.emitNarrowObservables || options.emitSupermassiveDocuments ? (0, import_graphql2.buildSchema)(
|
|
50
56
|
new import_graphql2.Source((0, import_fs.readFileSync)(options.schema, "utf-8"), options.schema)
|
|
@@ -95,12 +101,14 @@ async function formatModuleFactory(options) {
|
|
|
95
101
|
const reExportWatchNodeQuery = options.emitDocuments && definition.kind === "Fragment";
|
|
96
102
|
const components = [
|
|
97
103
|
typeText,
|
|
98
|
-
exports && options.
|
|
104
|
+
exports && options.unstable_emitExecutionDocumentText && exports.executionQueryDocument && printDocument(exports.executionQueryDocument),
|
|
105
|
+
exports && options.emitQueryDebugComments && !options.unstable_emitExecutionDocumentText && exports.executionQueryDocument && printDocumentComment(exports.executionQueryDocument),
|
|
99
106
|
exports && options.emitQueryDebugComments && exports.watchQueryDocument && printDocumentComment(exports.watchQueryDocument),
|
|
100
107
|
exports && printExports(exports),
|
|
101
108
|
reExportWatchNodeQuery && printWatchNodeQueryReExport(definition)
|
|
102
109
|
].filter(Boolean);
|
|
103
|
-
return
|
|
110
|
+
return `// @apollo-react-relay-duct-tape
|
|
111
|
+
/* tslint:disable */
|
|
104
112
|
/* eslint-disable */
|
|
105
113
|
// @ts-nocheck
|
|
106
114
|
${hash ? `/* ${hash} */
|
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, 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
|
|
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 unstable_emitExecutionDocumentText: boolean;\n}\n\nfunction printDocumentComment(document: DocumentNode) {\n return `/*\\n${print(document).trim()}\\n*/`;\n}\n\nfunction printDocument(document: DocumentNode) {\n return `\n// Note: executionDocumentText is necessary for Lazy AST and build-time operations analysis\nconst executionDocumentText = \\`${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.unstable_emitExecutionDocumentText &&\n exports.executionQueryDocument &&\n printDocument(exports.executionQueryDocument),\n exports &&\n options.emitQueryDebugComments &&\n !options.unstable_emitExecutionDocumentText &&\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 `// @apollo-react-relay-duct-tape\n/* 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;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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
|
@@ -13,6 +13,12 @@ function printDocumentComment(document) {
|
|
|
13
13
|
${print(document).trim()}
|
|
14
14
|
*/`;
|
|
15
15
|
}
|
|
16
|
+
function printDocument(document) {
|
|
17
|
+
return `
|
|
18
|
+
// Note: executionDocumentText is necessary for Lazy AST and build-time operations analysis
|
|
19
|
+
const executionDocumentText = \`${print(document).trim()}\`;
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
16
22
|
async function formatModuleFactory(options) {
|
|
17
23
|
const schema = options.emitNarrowObservables || options.emitSupermassiveDocuments ? buildSchema(
|
|
18
24
|
new Source(readFileSync(options.schema, "utf-8"), options.schema)
|
|
@@ -63,12 +69,14 @@ async function formatModuleFactory(options) {
|
|
|
63
69
|
const reExportWatchNodeQuery = options.emitDocuments && definition.kind === "Fragment";
|
|
64
70
|
const components = [
|
|
65
71
|
typeText,
|
|
66
|
-
exports && options.
|
|
72
|
+
exports && options.unstable_emitExecutionDocumentText && exports.executionQueryDocument && printDocument(exports.executionQueryDocument),
|
|
73
|
+
exports && options.emitQueryDebugComments && !options.unstable_emitExecutionDocumentText && exports.executionQueryDocument && printDocumentComment(exports.executionQueryDocument),
|
|
67
74
|
exports && options.emitQueryDebugComments && exports.watchQueryDocument && printDocumentComment(exports.watchQueryDocument),
|
|
68
75
|
exports && printExports(exports),
|
|
69
76
|
reExportWatchNodeQuery && printWatchNodeQueryReExport(definition)
|
|
70
77
|
].filter(Boolean);
|
|
71
|
-
return
|
|
78
|
+
return `// @apollo-react-relay-duct-tape
|
|
79
|
+
/* tslint:disable */
|
|
72
80
|
/* eslint-disable */
|
|
73
81
|
// @ts-nocheck
|
|
74
82
|
${hash ? `/* ${hash} */
|
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, 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
|
|
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 unstable_emitExecutionDocumentText: boolean;\n}\n\nfunction printDocumentComment(document: DocumentNode) {\n return `/*\\n${print(document).trim()}\\n*/`;\n}\n\nfunction printDocument(document: DocumentNode) {\n return `\n// Note: executionDocumentText is necessary for Lazy AST and build-time operations analysis\nconst executionDocumentText = \\`${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.unstable_emitExecutionDocumentText &&\n exports.executionQueryDocument &&\n printDocument(exports.executionQueryDocument),\n exports &&\n options.emitQueryDebugComments &&\n !options.unstable_emitExecutionDocumentText &&\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 `// @apollo-react-relay-duct-tape\n/* 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;AACpC,SAAS,oBAAoB;AAC7B,OAAO,yBAAyB;AAmBhC,SAAS,qBAAqB,UAAwB;AACpD,SAAO;AAAA,EAAO,MAAM,QAAQ,EAAE,KAAK;AAAA;AACrC;AAEA,SAAS,cAAc,UAAwB;AAC7C,SAAO;AAAA;AAAA,kCAEyB,MAAM,QAAQ,EAAE,KAAK;AAAA;AAEvD;AAEA,eAAsB,oBACpB,SACuB;AACvB,QAAM,SACJ,QAAQ,yBAAyB,QAAQ,4BACrC;AAAA,IACE,IAAI,OAAO,aAAa,QAAQ,QAAQ,OAAO,GAAG,QAAQ,MAAM;AAAA,EAClE,IACA;AAEN,MAAI;AAGJ,MAAI;AAGJ,MAAI,QAAQ,2BAA2B;AACrC,KAAC;AAAA,MACC;AAAA,MACA;AAAA,IACF,IAAI,MAAM,OAAO,4BAA4B;AAAA,EAC/C;AAEA,WAAS,gBACP,YACA,SACA,uBACA;AACA,UAAM,UAAkC,CAAC;AACzC,UAAM,mBAAmB,MAAM,SAAS,EAAE,YAAY,KAAK,CAAC;AA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,MAAM;AAAA,EACtB;AACF;AAGA,SAAS,4BAA4B,YAAsB;AACzD,QAAM,cACJ,WAAW,WAAW;AAAA,IACpB,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,IAAI,SAAS;AAAA,EACpD,KACA,WAAW,WAAW;AAAA,IACpB,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,IAAI,SAAS;AAAA,EACpD;AACF,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AACA,QAAM,eAAe,YAAY,KAAK,CAAC;AACvC;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,kHAAkH;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": []
|
|
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.8.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"duct-tape-compiler": "./lib/cli.js"
|