Skip to content

Commit b605638

Browse files
davimacedodouglasmuraoka
authored andcommitted
Fix: GraphQL _or operator not working (#5840)
1 parent 5398b6f commit b605638

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

spec/ParseGraphQLServer.spec.js

+38
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,44 @@ describe('ParseGraphQLServer', () => {
15231523
).toEqual(['someValue1', 'someValue3']);
15241524
});
15251525

1526+
it('should support _or operation', async () => {
1527+
await prepareData();
1528+
1529+
await parseGraphQLServer.parseGraphQLSchema.databaseController.schemaCache.clear();
1530+
1531+
const result = await apolloClient.query({
1532+
query: gql`
1533+
query {
1534+
objects {
1535+
findGraphQLClass(
1536+
where: {
1537+
_or: [
1538+
{ someField: { _eq: "someValue1" } }
1539+
{ someField: { _eq: "someValue2" } }
1540+
]
1541+
}
1542+
) {
1543+
results {
1544+
someField
1545+
}
1546+
}
1547+
}
1548+
}
1549+
`,
1550+
context: {
1551+
headers: {
1552+
'X-Parse-Master-Key': 'test',
1553+
},
1554+
},
1555+
});
1556+
1557+
expect(
1558+
result.data.objects.findGraphQLClass.results
1559+
.map(object => object.someField)
1560+
.sort()
1561+
).toEqual(['someValue1', 'someValue2']);
1562+
});
1563+
15261564
it('should support order, skip and limit arguments', async () => {
15271565
const promises = [];
15281566
for (let i = 0; i < 100; i++) {

src/Controllers/DatabaseController.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const validateQuery = (
119119
*/
120120
Object.keys(query).forEach(key => {
121121
const noCollisions = !query.$or.some(subq =>
122-
subq.hasOwnProperty(key)
122+
Object.hasOwnProperty.call(subq, key)
123123
);
124124
let hasNears = false;
125125
if (query[key] != null && typeof query[key] == 'object') {

0 commit comments

Comments
 (0)