Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5723,6 +5723,38 @@ describe('ParseGraphQLServer', () => {
expect(getResult.data.objects.someClasses.results.length).toEqual(2);
});

it('should support undefined array', async () => {
const schema = await new Parse.Schema('SomeClass');
schema.addArray('someArray');
await schema.save();

const obj = new Parse.Object('SomeClass');
await obj.save();

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

const getResult = await apolloClient.query({
query: gql`
query GetSomeObject($objectId: ID!) {
objects {
someClass(objectId: $objectId) {
objectId
someArray {
... on Element {
value
}
}
}
}
}
`,
variables: {
objectId: obj.id,
},
});
expect(getResult.data.objects.someClass.someArray).toEqual(null);
});

it('should support null values', async () => {
const createResult = await apolloClient.mutate({
mutation: gql`
Expand Down
1 change: 1 addition & 0 deletions src/GraphQL/loaders/parseClassTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ const load = (
description: `Use Inline Fragment on Array to get results: https://graphql.org/learn/queries/#inline-fragments`,
type,
async resolve(source) {
if (!source[field]) return null;
return source[field].map(async elem => {
if (
elem.className &&
Expand Down