Fix: GraphQL _or operator not working (#5840)

This commit is contained in:
Antonio Davi Macedo Coelho de Castro
2019-07-23 06:29:38 -07:00
committed by Douglas Muraoka
parent 5398b6f667
commit b605638415
2 changed files with 39 additions and 1 deletions

View File

@@ -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++) {

View File

@@ -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') {