I found that the result of the resolvers returns the same format ( standard query result). But I can’t find where the query result is actually parsed and transformed to a gql result. For the default query. I think defaultGraphQLTypes.loadArrayResult(this, parseClasses);
has something to do with…
I have a test written for problem,
`it(‘can resolve a custom query, that returns an array’, async () => {
const schemaController = await parseServer.config.databaseController.loadSchema();
await schemaController.addClassIfNotExists('SuperCar', {
engine: { type: 'String' },
doors: { type: 'Number' },
price: { type: 'String' },
mileage: { type: 'Number' },
gears: { type: 'Array' }
});
await new Parse.Object('SuperCar').save({
engine: 'petrol',
doors: 3,
price: '£7500',
mileage: 0,
gears: ['1', '2', '3', '4']
});
await new Parse.Object('SuperCar').save({
engine: 'petrol',
doors: 3,
price: '£7500',
mileage: 10000,
gears: ['1', '2', '3', '4', '5']
});
await Promise.all([
parseGraphQLServer.parseGraphQLController.cacheController.graphQL.clear(),
parseGraphQLServer.parseGraphQLSchema.schemaCache.clear(),
]);
Parse.Cloud.define('arrayOfSuperCar', async () => {
const superCars = await new Parse.Query('SuperCar').find({useMasterKey: true})
return superCars
});
const result = await apolloClient.query({
query: gql`
query FindSuperCar {
arrayOfSuperCar {
objectId
objectId
gears {
... on Element {
value
}
}
}
}
`,
})
expect(result.data.superCars.gears[2].value).toEqual('3');
});`