@graphitation/apollo-react-relay-duct-tape-compiler 1.8.9 → 1.8.11
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 +18 -2
- package/lib/formatModule.d.ts.map +1 -1
- package/lib/formatModule.js +4 -6
- package/lib/formatModule.js.map +2 -2
- package/lib/formatModule.mjs +4 -6
- package/lib/formatModule.mjs.map +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
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, 07 Jan 2026 22:51:24 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.8.11
|
|
8
|
+
|
|
9
|
+
Wed, 07 Jan 2026 22:51:24 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Strip __fragments field for non-query operations from fat/broad query (ikjotdhody@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 1.8.10
|
|
16
|
+
|
|
17
|
+
Tue, 06 Jan 2026 13:26:11 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Bump @graphitation/supermassive to v3.14.1
|
|
22
|
+
|
|
7
23
|
## 1.8.9
|
|
8
24
|
|
|
9
|
-
Mon, 05 Jan 2026 11:
|
|
25
|
+
Mon, 05 Jan 2026 11:02:15 GMT
|
|
10
26
|
|
|
11
27
|
### Patches
|
|
12
28
|
|
|
@@ -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;IACf,kCAAkC,EAAE,OAAO,CAAC;CAC7C;AAaD,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;IACf,kCAAkC,EAAE,OAAO,CAAC;CAC7C;AAaD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CAmGvB"}
|
package/lib/formatModule.js
CHANGED
|
@@ -67,12 +67,10 @@ async function formatModuleFactory(options) {
|
|
|
67
67
|
const exports = {};
|
|
68
68
|
const originalDocument = (0, import_graphql.parse)(docText, { noLocation: true });
|
|
69
69
|
const optimizedDocument = (0, import_optimize.optimizeDocumentNode)(originalDocument);
|
|
70
|
-
if (!
|
|
71
|
-
exports.executionQueryDocument = optimizedDocument;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
exports.executionQueryDocument = (0, import_stripFragmentReferenceFieldSelectionTransform.stripFragmentReferenceFieldSelectionTransform)(optimizedDocument);
|
|
75
|
-
}
|
|
70
|
+
if (!moduleName.endsWith("WatchNodeQuery.graphql")) {
|
|
71
|
+
exports.executionQueryDocument = (0, import_stripFragmentReferenceFieldSelectionTransform.stripFragmentReferenceFieldSelectionTransform)(optimizedDocument);
|
|
72
|
+
}
|
|
73
|
+
if (emitNarrowObservables) {
|
|
76
74
|
(0, import_invariant.default)(schema, "Expected a schema instance");
|
|
77
75
|
exports.watchQueryDocument = (0, import_reduceNodeWatchQueryTransform.reduceNodeWatchQueryTransform)(
|
|
78
76
|
schema,
|
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 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 (!
|
|
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;AAmBhC,SAAS,qBAAqB,UAAwB;AACpD,SAAO;AAAA,MAAO,sBAAM,QAAQ,EAAE,KAAK;AAAA;AACrC;AAEA,SAAS,cAAc,UAAwB;AAC7C,SAAO;AAAA;AAAA,sCAEyB,sBAAM,QAAQ,EAAE,KAAK;AAAA;AAEvD;AAEA,eAAsB,oBACpB,SACuB;AACvB,QAAM,SACJ,QAAQ,yBAAyB,QAAQ,gCACrC;AAAA,IACE,IAAI,2BAAO,wBAAa,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,uBAAmB,sBAAM,SAAS,EAAE,YAAY,KAAK,CAAC;AAC5D,UAAM,wBAAoB,sCAAqB,gBAAgB;AAE/D,QAAI,CAAC,
|
|
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 (!moduleName.endsWith(\"WatchNodeQuery.graphql\")) {\n exports.executionQueryDocument =\n stripFragmentReferenceFieldSelectionTransform(optimizedDocument);\n }\n if (emitNarrowObservables) {\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 =\n options.emitDocuments || options.unstable_emitExecutionDocumentText\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 && options.emitDocuments && 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;AAC7B,iCAAgC;AAmBhC,SAAS,qBAAqB,UAAwB;AACpD,SAAO;AAAA,MAAO,sBAAM,QAAQ,EAAE,KAAK;AAAA;AACrC;AAEA,SAAS,cAAc,UAAwB;AAC7C,SAAO;AAAA;AAAA,sCAEyB,sBAAM,QAAQ,EAAE,KAAK;AAAA;AAEvD;AAEA,eAAsB,oBACpB,SACuB;AACvB,QAAM,SACJ,QAAQ,yBAAyB,QAAQ,gCACrC;AAAA,IACE,IAAI,2BAAO,wBAAa,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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A,IAClE,EAAE,OAAO,OAAO;AAEhB,WAAO;AAAA;AAAA;AAAA;AAAA,EAIT,OAAO,MAAM;AAAA,IAAc;AAAA,EAC3B,WAAW,KAAK,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,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
|
@@ -35,12 +35,10 @@ async function formatModuleFactory(options) {
|
|
|
35
35
|
const exports = {};
|
|
36
36
|
const originalDocument = parse(docText, { noLocation: true });
|
|
37
37
|
const optimizedDocument = optimizeDocumentNode(originalDocument);
|
|
38
|
-
if (!
|
|
39
|
-
exports.executionQueryDocument = optimizedDocument;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.executionQueryDocument = stripFragmentReferenceFieldSelectionTransform(optimizedDocument);
|
|
43
|
-
}
|
|
38
|
+
if (!moduleName.endsWith("WatchNodeQuery.graphql")) {
|
|
39
|
+
exports.executionQueryDocument = stripFragmentReferenceFieldSelectionTransform(optimizedDocument);
|
|
40
|
+
}
|
|
41
|
+
if (emitNarrowObservables) {
|
|
44
42
|
invariant(schema, "Expected a schema instance");
|
|
45
43
|
exports.watchQueryDocument = reduceNodeWatchQueryTransform(
|
|
46
44
|
schema,
|
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 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 (!
|
|
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;AAC5D,UAAM,oBAAoB,qBAAqB,gBAAgB;AAE/D,QAAI,CAAC,
|
|
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 (!moduleName.endsWith(\"WatchNodeQuery.graphql\")) {\n exports.executionQueryDocument =\n stripFragmentReferenceFieldSelectionTransform(optimizedDocument);\n }\n if (emitNarrowObservables) {\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 =\n options.emitDocuments || options.unstable_emitExecutionDocumentText\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 && options.emitDocuments && 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,uB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A;AAAA;AAAA,EAIT,OAAO,MAAM;AAAA,IAAc;AAAA,EAC3B,WAAW,KAAK,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.8.
|
|
5
|
+
"version": "1.8.11",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"duct-tape-compiler": "./lib/cli.js"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"graphql": "^15.0.0",
|
|
45
|
-
"@graphitation/supermassive": "^3.14.
|
|
45
|
+
"@graphitation/supermassive": "^3.14.1",
|
|
46
46
|
"typescript": "^5.5.3"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|