Skip to content

Commit

Permalink
fix(createRequest): selectionSet overrides fieldNodes (#1820)
Browse files Browse the repository at this point in the history
selectionSet option is used with bare execution, where fieldNodes is not present, without issue.

with type merging, info.fieldNodes and fieldNodes may be specified, but selectionSet should override, as there may be situation when both appear but selectionSet desired, unlikely for them both to appear but fieldNodes to be desired, as fieldNodes is auto generated, and selectionSet is more likely to be created manually.
  • Loading branch information
yaacovCR committed Jul 28, 2020
1 parent cb717e6 commit 1025a2c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/delegate/src/createRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ export function createRequest({
selectionSet,
fieldNodes,
}: ICreateRequest): Request {
let newSelectionSet: SelectionSetNode = selectionSet;
let newSelectionSet: SelectionSetNode;
let argumentNodeMap: Record<string, ArgumentNode>;

if (fieldNodes == null) {
if (selectionSet != null) {
newSelectionSet = selectionSet;
argumentNodeMap = Object.create(null);
} else {
const selections: Array<SelectionNode> = fieldNodes.reduce(
Expand Down

0 comments on commit 1025a2c

Please sign in to comment.