Skip to content

Commit

Permalink
sort object keys in missing cases
Browse files Browse the repository at this point in the history
Reviewed By: tyao1

Differential Revision: D20786719

fbshipit-source-id: 70de5fd4abbb090fbedbe83d19a13e29873271f0
  • Loading branch information
kassens authored and facebook-github-bot committed Apr 1, 2020
1 parent baa11ce commit 3d218a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
40 changes: 26 additions & 14 deletions packages/relay-compiler/codegen/NormalizationCodeGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {
Stream,
Condition,
InlineFragment,
ModuleImport,
LocalArgumentDefinition,
} from '../core/IR';
import type {Schema, TypeID} from '../core/Schema';
Expand Down Expand Up @@ -374,9 +375,8 @@ function generateLinkedField(
}

function generateModuleImport(
node,
key,
sortObjectKeys,
node: ModuleImport,
sortObjectKeys: boolean,
): NormalizationModuleImport {
const fragmentName = node.name;
const regExpMatch = fragmentName.match(
Expand Down Expand Up @@ -595,17 +595,29 @@ function generateArgumentValue(
};
}
case 'ListValue': {
return {
kind: 'ListValue',
name: name,
items: value.items.map((item, index) => {
return generateArgumentValue(
`${name}.${index}`,
item,
sortObjectKeys,
);
}),
};
return sortObjectKeys
? {
items: value.items.map((item, index) => {
return generateArgumentValue(
`${name}.${index}`,
item,
sortObjectKeys,
);
}),
kind: 'ListValue',
name: name,
}
: {
kind: 'ListValue',
name: name,
items: value.items.map((item, index) => {
return generateArgumentValue(
`${name}.${index}`,
item,
sortObjectKeys,
);
}),
};
}
default:
throw createUserError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,6 @@ Request {
ObjectValue {
fields: [
ListValue {
name: "inputs",
items: [
ObjectValue {
fields: [
Expand All @@ -1632,6 +1631,7 @@ Request {
variableName: "searchInputLast",
},
],
name: "inputs",
},
Variable {
name: "query",
Expand Down Expand Up @@ -1788,7 +1788,6 @@ Request {
alias: null,
args: [
ListValue {
name: "waypoints",
items: [
ObjectValue {
fields: [
Expand Down Expand Up @@ -1830,6 +1829,7 @@ Request {
name: "waypoints.2",
},
],
name: "waypoints",
},
],
concreteType: "Route",
Expand Down

0 comments on commit 3d218a7

Please sign in to comment.