Skip to content

Commit

Permalink
Fix: GraphQL _or operator not working (parse-community#5840)
Browse files Browse the repository at this point in the history
  • Loading branch information
davimacedo authored and douglasmuraoka committed Jul 23, 2019
1 parent e272c06 commit 87f0117
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 38 additions & 0 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,44 @@ describe('ParseGraphQLServer', () => {
).toEqual(['someValue1', 'someValue3']);
});

it('should support _or operation', async () => {
await prepareData();

await parseGraphQLServer.parseGraphQLSchema.databaseController.schemaCache.clear();

const result = await apolloClient.query({
query: gql`
query {
objects {
findGraphQLClass(
where: {
_or: [
{ someField: { _eq: "someValue1" } }
{ someField: { _eq: "someValue2" } }
]
}
) {
results {
someField
}
}
}
}
`,
context: {
headers: {
'X-Parse-Master-Key': 'test',
},
},
});

expect(
result.data.objects.findGraphQLClass.results
.map(object => object.someField)
.sort()
).toEqual(['someValue1', 'someValue2']);
});

it('should support order, skip and limit arguments', async () => {
const promises = [];
for (let i = 0; i < 100; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/DatabaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const validateQuery = (
*/
Object.keys(query).forEach(key => {
const noCollisions = !query.$or.some(subq =>
subq.hasOwnProperty(key)
Object.hasOwnProperty.call(subq, key)
);
let hasNears = false;
if (query[key] != null && typeof query[key] == 'object') {
Expand Down

0 comments on commit 87f0117

Please sign in to comment.