-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
GQL format array results into elements from cloud functions #7506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GQL format array results into elements from cloud functions #7506
Conversation
|
Thanks for opening this PR! What kind of help do you need to find a solution? What is the step you are stuck at? |
|
I can see that we resolve the cloud functions in I have seen that we run It would be nice if we transform arrays of class objects into nodes and edges for cloud functions as well. That is more of a proposal rather than an issue 😃. |
|
it seems that everything works correctly with the last version of Parse Server. The following test actually pass 🚀 fit('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
gears {
... on Element {
value
}
}
}
}
`,
});
expect(result.data.arrayOfSuperCar[0].gears[2].value).toEqual('3');
});On your provided test, the "expect" was not correct. Please could you adjust your test to correctly reproduce the original issue, if it still exists 🙂 |
|
@mtrezza we can maybe close this one ? |
|
Before we close, is there anything in this PR that could be worth merging? Like the test case in your previous comment? Or does that test already exist? |
New Pull Request Checklist
Issue Description
Parse does not convert arrays into arrays of elements for cloud functions.
TODO: We could perhaps adopt the relay, node edges architecture on cloud functions that return arrays of parse objects.
Related issue: #7197
Approach
The initial commit just contains an example that shows the error. I need help to find the solution to the issue.
TODOs before merging