This commit is contained in:
Eloy Durán 2021-10-07 15:05:34 +02:00
Родитель b47507d4ec
Коммит c5269f511a
2 изменённых файлов: 34 добавлений и 9 удалений

Просмотреть файл

@ -27,13 +27,26 @@ export function createImportDocumentsTransform(): ts.TransformerFactory<ts.Sourc
const documentNodes = createGraphQLDocumentNodes(node);
if (documentNodes) {
const [importDeclaration, replacementNode] = documentNodes;
// TODO: This file checking should not exist and is probably not performant.
const artefactFile =
path.join(
path.dirname(node.getSourceFile().fileName),
(importDeclaration.moduleSpecifier as ts.StringLiteral).text
) + ".ts";
if (fs.existsSync(artefactFile)) {
// Because we currently only emit new watch queries for fragments
// on Node types, we cannot just assume the artefact exists for
// every fragment definition. So check if it exists before emitting
// the import.
//
// TODO: This file checking should not exist and is probably not
// performant.
//
// NOTE: In our test case node.getSourceFile() returns undefined.
let emitImport = true;
const sourceFile: ts.SourceFile | undefined = node.getSourceFile();
if (sourceFile) {
const artefactFile =
path.join(
path.dirname(sourceFile.fileName),
(importDeclaration.moduleSpecifier as ts.StringLiteral).text
) + ".ts";
emitImport = fs.existsSync(artefactFile);
}
if (emitImport) {
imports.push(importDeclaration);
return replacementNode;
}

Просмотреть файл

@ -1,5 +1,17 @@
diff --git a/node_modules/@apollo/client/cache/cache.cjs.js b/node_modules/@apollo/client/cache/cache.cjs.js
index c9ad278..5cf48a9 100644
--- a/node_modules/@apollo/client/cache/cache.cjs.js
+++ b/node_modules/@apollo/client/cache/cache.cjs.js
@@ -1670,6 +1670,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
return {
args: argsFromFieldSpecifier(fieldSpec),
field: fieldSpec.field || null,
+ query: context.query,
fieldName: fieldName,
storeFieldName: storeFieldName,
variables: variables,
diff --git a/node_modules/@apollo/client/cache/inmemory/policies.d.ts b/node_modules/@apollo/client/cache/inmemory/policies.d.ts
index 4ac7a5d..1e5a736 100644
index 4ac7a5d..28a8da6 100644
--- a/node_modules/@apollo/client/cache/inmemory/policies.d.ts
+++ b/node_modules/@apollo/client/cache/inmemory/policies.d.ts
@@ -1,4 +1,4 @@
@ -17,7 +29,7 @@ index 4ac7a5d..1e5a736 100644
isReference: typeof isReference;
toReference: ToReferenceFunction;
diff --git a/node_modules/@apollo/client/cache/inmemory/policies.js b/node_modules/@apollo/client/cache/inmemory/policies.js
index 04b892a..c91b170 100644
index 04b892a..f73e6fd 100644
--- a/node_modules/@apollo/client/cache/inmemory/policies.js
+++ b/node_modules/@apollo/client/cache/inmemory/policies.js
@@ -354,6 +354,7 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex