Fix: GraphQL _or operator not working (#5840)
This commit is contained in:
committed by
Douglas Muraoka
parent
5398b6f667
commit
b605638415
@@ -1523,6 +1523,44 @@ describe('ParseGraphQLServer', () => {
|
|||||||
).toEqual(['someValue1', 'someValue3']);
|
).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 () => {
|
it('should support order, skip and limit arguments', async () => {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ const validateQuery = (
|
|||||||
*/
|
*/
|
||||||
Object.keys(query).forEach(key => {
|
Object.keys(query).forEach(key => {
|
||||||
const noCollisions = !query.$or.some(subq =>
|
const noCollisions = !query.$or.some(subq =>
|
||||||
subq.hasOwnProperty(key)
|
Object.hasOwnProperty.call(subq, key)
|
||||||
);
|
);
|
||||||
let hasNears = false;
|
let hasNears = false;
|
||||||
if (query[key] != null && typeof query[key] == 'object') {
|
if (query[key] != null && typeof query[key] == 'object') {
|
||||||
|
|||||||
Reference in New Issue
Block a user