@graphitation/apollo-react-relay-duct-tape-compiler 1.2.2 → 1.2.4
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 +20 -2
- package/lib/compilerTransforms/utils.js +1 -1
- package/lib/compilerTransforms/utils.js.map +2 -2
- package/lib/compilerTransforms/utils.mjs +1 -1
- package/lib/compilerTransforms/utils.mjs.map +2 -2
- package/lib/formatModule.d.ts.map +1 -1
- package/lib/formatModule.js +10 -4
- package/lib/formatModule.js.map +2 -2
- package/lib/formatModule.mjs +10 -4
- package/lib/formatModule.mjs.map +2 -2
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
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 Thu, 21 Sep 2023 06:27:50 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.2.4
|
|
8
|
+
|
|
9
|
+
Thu, 21 Sep 2023 06:27:50 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Add exports entry for types to package.json (sverre.johansen@gmail.com)
|
|
14
|
+
- Bump @graphitation/graphql-js-tag to v0.9.1
|
|
15
|
+
- Bump @graphitation/supermassive-ast to v2.0.1
|
|
16
|
+
|
|
17
|
+
## 1.2.3
|
|
18
|
+
|
|
19
|
+
Wed, 16 Aug 2023 06:31:21 GMT
|
|
20
|
+
|
|
21
|
+
### Patches
|
|
22
|
+
|
|
23
|
+
- Various PeopleApp fixes (eloy.de.enige@gmail.com)
|
|
24
|
+
|
|
7
25
|
## 1.2.2
|
|
8
26
|
|
|
9
|
-
Tue, 25 Jul 2023 08:
|
|
27
|
+
Tue, 25 Jul 2023 08:18:03 GMT
|
|
10
28
|
|
|
11
29
|
### Patches
|
|
12
30
|
|
|
@@ -39,5 +39,5 @@ function implementsNodeInterface(context, fragmentDefinition) {
|
|
|
39
39
|
nodeType && schema.isInterface(nodeType),
|
|
40
40
|
"Expected schema to define a Node interface in order to support narrow observables."
|
|
41
41
|
);
|
|
42
|
-
return schema.
|
|
42
|
+
return schema.mayImplement(fragmentDefinition.type, nodeType);
|
|
43
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/compilerTransforms/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import invariant from \"invariant\";\nimport { CompilerContext, Fragment } from \"relay-compiler\";\n\nexport function implementsNodeInterface(\n context: CompilerContext,\n fragmentDefinition: Fragment,\n) {\n const schema = context.getSchema();\n const nodeType = schema.getTypeFromString(\"Node\");\n invariant(\n nodeType && schema.isInterface(nodeType),\n \"Expected schema to define a Node interface in order to support narrow observables.\",\n );\n return schema.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AAGf,SAAS,wBACd,SACA,oBACA;AACA,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,OAAO,kBAAkB,MAAM;AAChD,uBAAAA;AAAA,IACE,YAAY,OAAO,YAAY,QAAQ;AAAA,IACvC;AAAA,EACF;AACA,SAAO,OAAO,
|
|
4
|
+
"sourcesContent": ["import invariant from \"invariant\";\nimport { CompilerContext, Fragment } from \"relay-compiler\";\n\nexport function implementsNodeInterface(\n context: CompilerContext,\n fragmentDefinition: Fragment,\n) {\n const schema = context.getSchema();\n const nodeType = schema.getTypeFromString(\"Node\");\n invariant(\n nodeType && schema.isInterface(nodeType),\n \"Expected schema to define a Node interface in order to support narrow observables.\",\n );\n return schema.mayImplement(fragmentDefinition.type, nodeType);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsB;AAGf,SAAS,wBACd,SACA,oBACA;AACA,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,OAAO,kBAAkB,MAAM;AAChD,uBAAAA;AAAA,IACE,YAAY,OAAO,YAAY,QAAQ;AAAA,IACvC;AAAA,EACF;AACA,SAAO,OAAO,aAAa,mBAAmB,MAAM,QAAQ;AAC9D;",
|
|
6
6
|
"names": ["invariant"]
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ function implementsNodeInterface(context, fragmentDefinition) {
|
|
|
7
7
|
nodeType && schema.isInterface(nodeType),
|
|
8
8
|
"Expected schema to define a Node interface in order to support narrow observables."
|
|
9
9
|
);
|
|
10
|
-
return schema.
|
|
10
|
+
return schema.mayImplement(fragmentDefinition.type, nodeType);
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
13
|
implementsNodeInterface
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/compilerTransforms/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import invariant from \"invariant\";\nimport { CompilerContext, Fragment } from \"relay-compiler\";\n\nexport function implementsNodeInterface(\n context: CompilerContext,\n fragmentDefinition: Fragment,\n) {\n const schema = context.getSchema();\n const nodeType = schema.getTypeFromString(\"Node\");\n invariant(\n nodeType && schema.isInterface(nodeType),\n \"Expected schema to define a Node interface in order to support narrow observables.\",\n );\n return schema.
|
|
5
|
-
"mappings": ";AAAA,OAAO,eAAe;AAGf,SAAS,wBACd,SACA,oBACA;AACA,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,OAAO,kBAAkB,MAAM;AAChD;AAAA,IACE,YAAY,OAAO,YAAY,QAAQ;AAAA,IACvC;AAAA,EACF;AACA,SAAO,OAAO,
|
|
4
|
+
"sourcesContent": ["import invariant from \"invariant\";\nimport { CompilerContext, Fragment } from \"relay-compiler\";\n\nexport function implementsNodeInterface(\n context: CompilerContext,\n fragmentDefinition: Fragment,\n) {\n const schema = context.getSchema();\n const nodeType = schema.getTypeFromString(\"Node\");\n invariant(\n nodeType && schema.isInterface(nodeType),\n \"Expected schema to define a Node interface in order to support narrow observables.\",\n );\n return schema.mayImplement(fragmentDefinition.type, nodeType);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,eAAe;AAGf,SAAS,wBACd,SACA,oBACA;AACA,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,OAAO,kBAAkB,MAAM;AAChD;AAAA,IACE,YAAY,OAAO,YAAY,QAAQ;AAAA,IACvC;AAAA,EACF;AACA,SAAO,OAAO,aAAa,mBAAmB,MAAM,QAAQ;AAC9D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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,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,CAwFvB"}
|
package/lib/formatModule.js
CHANGED
|
@@ -74,11 +74,11 @@ function formatModuleFactory(options) {
|
|
|
74
74
|
if (options.emitSupermassiveDocuments) {
|
|
75
75
|
({ addTypesToRequestDocument } = yield import("@graphitation/supermassive-ast"));
|
|
76
76
|
}
|
|
77
|
-
function generateExports(moduleName, docText) {
|
|
77
|
+
function generateExports(moduleName, docText, emitNarrowObservables) {
|
|
78
78
|
const exports = {};
|
|
79
79
|
const originalDocument = (0, import_graphql.parse)(docText, { noLocation: true });
|
|
80
80
|
const optimizedDocument = (0, import_optimize.optimizeDocumentNode)(originalDocument);
|
|
81
|
-
if (!
|
|
81
|
+
if (!emitNarrowObservables) {
|
|
82
82
|
exports.executionQueryDocument = optimizedDocument;
|
|
83
83
|
} else {
|
|
84
84
|
if (!moduleName.endsWith("WatchNodeQuery.graphql")) {
|
|
@@ -101,7 +101,11 @@ function formatModuleFactory(options) {
|
|
|
101
101
|
return exports;
|
|
102
102
|
}
|
|
103
103
|
return ({ docText, hash, moduleName, typeText, definition }) => {
|
|
104
|
-
const exports = options.emitDocuments ? docText && generateExports(
|
|
104
|
+
const exports = options.emitDocuments ? docText && generateExports(
|
|
105
|
+
moduleName,
|
|
106
|
+
docText,
|
|
107
|
+
options.emitNarrowObservables && definition.kind === "Request" && definition.root.operation === "query"
|
|
108
|
+
) : null;
|
|
105
109
|
const reExportWatchNodeQuery = options.emitDocuments && definition.kind === "Fragment";
|
|
106
110
|
const components = [
|
|
107
111
|
typeText,
|
|
@@ -125,7 +129,9 @@ function printWatchNodeQueryReExport(definition) {
|
|
|
125
129
|
) || definition.directives.find(
|
|
126
130
|
(d) => d.name === "refetchable" && d.loc.kind === "Generated"
|
|
127
131
|
);
|
|
128
|
-
|
|
132
|
+
if (!refetchable) {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
129
135
|
const queryNameArg = refetchable.args[0];
|
|
130
136
|
(0, import_invariant.default)(
|
|
131
137
|
queryNameArg.name === "queryName" && queryNameArg.value.kind === "Literal",
|
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 {
|
|
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;AAehC,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,QAAQ,2BAA2B;AACrC,OAAC,EAAE,0BAA0B,IAAI,MAAM,OACrC,gCACF;AAAA,IACF;AAEA,aAAS,
|
|
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 addTypesToRequestDocument:\n | undefined\n | typeof import(\"@graphitation/supermassive-ast\").addTypesToRequestDocument;\n if (options.emitSupermassiveDocuments) {\n ({ addTypesToRequestDocument } = await import(\n \"@graphitation/supermassive-ast\"\n ));\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 (addTypesToRequestDocument && exports.executionQueryDocument) {\n invariant(schema, \"Expected a schema instance\");\n exports.executionQueryDocument = addTypesToRequestDocument(\n schema,\n exports.executionQueryDocument,\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"],
|
|
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;AAehC,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,QAAQ,2BAA2B;AACrC,OAAC,EAAE,0BAA0B,IAAI,MAAM,OACrC,gCACF;AAAA,IACF;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,kBAAQ,6BACN,oGAA8C,iBAAiB;AAAA,QACnE;AAEA,6BAAAC,SA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,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;",
|
|
6
6
|
"names": ["import_graphql", "invariant", "dedupeJSONStringify"]
|
|
7
7
|
}
|
package/lib/formatModule.mjs
CHANGED
|
@@ -43,11 +43,11 @@ function formatModuleFactory(options) {
|
|
|
43
43
|
if (options.emitSupermassiveDocuments) {
|
|
44
44
|
({ addTypesToRequestDocument } = yield import("@graphitation/supermassive-ast"));
|
|
45
45
|
}
|
|
46
|
-
function generateExports(moduleName, docText) {
|
|
46
|
+
function generateExports(moduleName, docText, emitNarrowObservables) {
|
|
47
47
|
const exports = {};
|
|
48
48
|
const originalDocument = parse(docText, { noLocation: true });
|
|
49
49
|
const optimizedDocument = optimizeDocumentNode(originalDocument);
|
|
50
|
-
if (!
|
|
50
|
+
if (!emitNarrowObservables) {
|
|
51
51
|
exports.executionQueryDocument = optimizedDocument;
|
|
52
52
|
} else {
|
|
53
53
|
if (!moduleName.endsWith("WatchNodeQuery.graphql")) {
|
|
@@ -70,7 +70,11 @@ function formatModuleFactory(options) {
|
|
|
70
70
|
return exports;
|
|
71
71
|
}
|
|
72
72
|
return ({ docText, hash, moduleName, typeText, definition }) => {
|
|
73
|
-
const exports = options.emitDocuments ? docText && generateExports(
|
|
73
|
+
const exports = options.emitDocuments ? docText && generateExports(
|
|
74
|
+
moduleName,
|
|
75
|
+
docText,
|
|
76
|
+
options.emitNarrowObservables && definition.kind === "Request" && definition.root.operation === "query"
|
|
77
|
+
) : null;
|
|
74
78
|
const reExportWatchNodeQuery = options.emitDocuments && definition.kind === "Fragment";
|
|
75
79
|
const components = [
|
|
76
80
|
typeText,
|
|
@@ -94,7 +98,9 @@ function printWatchNodeQueryReExport(definition) {
|
|
|
94
98
|
) || definition.directives.find(
|
|
95
99
|
(d) => d.name === "refetchable" && d.loc.kind === "Generated"
|
|
96
100
|
);
|
|
97
|
-
|
|
101
|
+
if (!refetchable) {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
98
104
|
const queryNameArg = refetchable.args[0];
|
|
99
105
|
invariant(
|
|
100
106
|
queryNameArg.name === "queryName" && queryNameArg.value.kind === "Literal",
|
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 {
|
|
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;AAehC,SAAS,qBAAqB,UAAwB;AACpD,SAAO;AAAA,EAAO,MAAM,QAAQ,EAAE,KAAK;AAAA;AACrC;AAEA,SAAsB,oBACpB,SACuB;AAAA;AACvB,UAAM,SACJ,QAAQ,yBAAyB,QAAQ,4BACrC;AAAA,MACE,IAAI,OAAO,aAAa,QAAQ,QAAQ,OAAO,GAAG,QAAQ,MAAM;AAAA,IAClE,IACA;AAEN,QAAI;AAGJ,QAAI,QAAQ,2BAA2B;AACrC,OAAC,EAAE,0BAA0B,IAAI,MAAM,OACrC,gCACF;AAAA,IACF;AAEA,aAAS,
|
|
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 addTypesToRequestDocument:\n | undefined\n | typeof import(\"@graphitation/supermassive-ast\").addTypesToRequestDocument;\n if (options.emitSupermassiveDocuments) {\n ({ addTypesToRequestDocument } = await import(\n \"@graphitation/supermassive-ast\"\n ));\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 (addTypesToRequestDocument && exports.executionQueryDocument) {\n invariant(schema, \"Expected a schema instance\");\n exports.executionQueryDocument = addTypesToRequestDocument(\n schema,\n exports.executionQueryDocument,\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"],
|
|
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;AAehC,SAAS,qBAAqB,UAAwB;AACpD,SAAO;AAAA,EAAO,MAAM,QAAQ,EAAE,KAAK;AAAA;AACrC;AAEA,SAAsB,oBACpB,SACuB;AAAA;AACvB,UAAM,SACJ,QAAQ,yBAAyB,QAAQ,4BACrC;AAAA,MACE,IAAI,OAAO,aAAa,QAAQ,QAAQ,OAAO,GAAG,QAAQ,MAAM;AAAA,IAClE,IACA;AAEN,QAAI;AAGJ,QAAI,QAAQ,2BAA2B;AACrC,OAAC,EAAE,0BAA0B,IAAI,MAAM,OACrC,gCACF;AAAA,IACF;AAEA,aAAS,gBACP,YACA,SACA,uBACA;AACA,YAAM,UAAkC,CAAC;AACzC,YAAM,mBAAmB,MAAM,SAAS,EAAE,YAAY,KAAK,CAAC;AAC5D,YAAM,oBAAoB,qBAAqB,gBAAgB;AAE/D,UAAI,CAAC,uBAAuB;AAC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AC,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;",
|
|
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.2.
|
|
5
|
+
"version": "1.2.4",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"duct-tape-compiler": "./lib/cli.js"
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"just": "monorepo-scripts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@graphitation/graphql-js-tag": "^0.9.
|
|
23
|
+
"@graphitation/graphql-js-tag": "^0.9.1",
|
|
24
24
|
"@graphql-tools/optimize": "^1.1.1",
|
|
25
25
|
"relay-compiler": "^12.0.0",
|
|
26
26
|
"relay-compiler-language-typescript": "^15.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@graphitation/graphql-js-tag": "^0.9.
|
|
29
|
+
"@graphitation/graphql-js-tag": "^0.9.1",
|
|
30
30
|
"@graphitation/supermassive-ast": "*",
|
|
31
31
|
"@types/dedent": "^0.7.0",
|
|
32
32
|
"@types/jest": "^26.0.22",
|
|
@@ -41,17 +41,19 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"graphql": "^15.0.0",
|
|
44
|
-
"@graphitation/supermassive-ast": "^2.0.
|
|
44
|
+
"@graphitation/supermassive-ast": "^2.0.1",
|
|
45
45
|
"typescript": "^4.3.5"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
+
"types": "./lib/index.d.ts",
|
|
50
51
|
"module": "./lib/index.mjs",
|
|
51
52
|
"exports": {
|
|
52
53
|
".": {
|
|
53
54
|
"import": "./lib/index.mjs",
|
|
54
|
-
"require": "./lib/index.js"
|
|
55
|
+
"require": "./lib/index.js",
|
|
56
|
+
"types": "./lib/index.d.ts"
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
}
|