Skip to content

Commit

Permalink
remove redundant check for node type
Browse files Browse the repository at this point in the history
Summary:
Just a minor update before making a broader change to the code.

Probably due to some code moves, there was a redundant check for the `generatedNode.kind` that we can get rid of.

Reviewed By: tyao1

Differential Revision: D20796511

fbshipit-source-id: c706eb82fccefad3408c92f888d7ce8cd81f8958
  • Loading branch information
kassens authored and facebook-github-bot committed Apr 2, 2020
1 parent 640cf9c commit 2edce9f
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions packages/relay-compiler/codegen/writeRelayGeneratedFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ async function writeRelayGeneratedFile(
writeQueryParameters &&
oldRequestParameters &&
queryParametersFilename != null &&
generatedNode.kind === RelayConcreteNode.REQUEST &&
generatedNode.params.operationKind === 'query'
) {
writeQueryParameters(
Expand All @@ -143,30 +142,21 @@ async function writeRelayGeneratedFile(
return null;
}
if (persistQuery) {
switch (generatedNode.kind) {
case RelayConcreteNode.REQUEST:
const {text} = generatedNode.params;
invariant(
text != null,
'writeRelayGeneratedFile: Expected `text` in order to persist query',
);
generatedNode = {
...generatedNode,
params: {
id: await persistQuery(text),
metadata: generatedNode.params.metadata,
name: generatedNode.params.name,
operationKind: generatedNode.params.operationKind,
text: null,
},
};
break;
case RelayConcreteNode.FRAGMENT:
// Do not persist fragments.
break;
default:
(generatedNode.kind: empty);
}
const {text} = generatedNode.params;
invariant(
text != null,
'writeRelayGeneratedFile: Expected `text` in order to persist query',
);
generatedNode = {
...generatedNode,
params: {
id: await persistQuery(text),
metadata: generatedNode.params.metadata,
name: generatedNode.params.name,
operationKind: generatedNode.params.operationKind,
text: null,
},
};
}
}

Expand Down

0 comments on commit 2edce9f

Please sign in to comment.