Skip to content

Commit

Permalink
Remove context.clientOnly tracking from executeSelectionSetImpl.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed May 20, 2021
1 parent 2de299a commit 9ec7f17
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/cache/core/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class MissingFieldError extends Error {
public readonly message: string,
public readonly path: (string | number)[],
public readonly query: import('graphql').DocumentNode,
public readonly clientOnly: boolean,
public readonly variables?: Record<string, any>,
) {
super(message);
Expand Down
4 changes: 0 additions & 4 deletions src/cache/inmemory/__tests__/entityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1213,14 +1213,12 @@ describe('EntityStore', () => {
'Can\'t find field \'hobby\' on Author:{"name":"Ted Chiang"} object',
["authorOfBook", "hobby"],
expect.anything(), // query
false, // clientOnly
expect.anything(), // variables
),
new MissingFieldError(
'Can\'t find field \'publisherOfBook\' on ROOT_QUERY object',
["publisherOfBook"],
expect.anything(), // query
false, // clientOnly
expect.anything(), // variables
),
],
Expand Down Expand Up @@ -1814,7 +1812,6 @@ describe('EntityStore', () => {
"Dangling reference to missing Author:2 object",
["book", "author"],
expect.anything(), // query
false, // clientOnly
expect.anything(), // variables
),
];
Expand Down Expand Up @@ -2084,7 +2081,6 @@ describe('EntityStore', () => {
'Can\'t find field \'title\' on Book:{"isbn":"031648637X"} object',
["book", "title"],
expect.anything(), // query
false, // clientOnly
expect.anything(), // variables
),
],
Expand Down
1 change: 0 additions & 1 deletion src/cache/inmemory/__tests__/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,6 @@ describe("type policies", function () {
`Can't find field 'result' on Job:{"name":"Job #${jobNumber}"} object`,
["jobs", jobNumber - 1, "result"],
expect.anything(), // query
false, // clientOnly
expect.anything(), // variables
);
}
Expand Down
2 changes: 0 additions & 2 deletions src/cache/inmemory/__tests__/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ describe('reading from the store', () => {
}`,
["normal", "missing"],
query,
false, // clientOnly
{}, // variables
),
new MissingFieldError(
Expand All @@ -738,7 +737,6 @@ describe('reading from the store', () => {
}`,
["clientOnly", "missing"],
query,
true, // clientOnly
{}, // variables
),
]);
Expand Down
19 changes: 0 additions & 19 deletions src/cache/inmemory/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ interface ReadContext extends ReadMergeModifyContext {
canonizeResults: boolean;
fragmentMap: FragmentMap;
path: (string | number)[];
clientOnly: boolean;
};

export type ExecResult<R = any> = {
Expand All @@ -62,7 +61,6 @@ function missingFromInvariant(
err.message,
context.path.slice(),
context.query,
context.clientOnly,
context.variables,
);
}
Expand Down Expand Up @@ -241,7 +239,6 @@ export class StoreReader {
canonizeResults,
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
path: [],
clientOnly: false,
},
});

Expand Down Expand Up @@ -344,20 +341,6 @@ export class StoreReader {
const resultName = resultKeyNameFromField(selection);
context.path.push(resultName);

// If this field has an @client directive, then the field and
// everything beneath it is client-only, meaning it will never be
// sent to the server.
const wasClientOnly = context.clientOnly;
// Once we enter a client-only subtree of the query, we can avoid
// repeatedly checking selection.directives.
context.clientOnly = wasClientOnly || !!(
// We don't use the hasDirectives helper here, because it looks
// for directives anywhere inside the AST node, whereas we only
// care about directives directly attached to this field.
selection.directives &&
selection.directives.some(d => d.name.value === "client")
);

if (fieldValue === void 0) {
if (!addTypenameToDocument.added(selection)) {
getMissing().push(
Expand Down Expand Up @@ -407,8 +390,6 @@ export class StoreReader {
objectsToMerge.push({ [resultName]: fieldValue });
}

context.clientOnly = wasClientOnly;

invariant(context.path.pop() === resultName);

} else {
Expand Down

0 comments on commit 9ec7f17

Please sign in to comment.