Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ ___
- Added runtime deprecation warnings (Manuel Trezza) [#7451](https://github.com/parse-community/parse-server/pull/7451)
- Add ability to pass context of an object via a header, X-Parse-Cloud-Context, for Cloud Code triggers. The header addition allows client SDK's to add context without injecting _context in the body of JSON objects (Corey Baker) [#7437](https://github.com/parse-community/parse-server/pull/7437)
- Add CI check to add changelog entry (Manuel Trezza) [#7512](https://github.com/parse-community/parse-server/pull/7512)
- Allow a pointer to be removed using GraphQL (Chris Bland) [#7517](https://github.com/parse-community/parse-server/issues/7517)

## 4.10.2
[Full Changelog](https://github.com/parse-community/parse-server/compare/4.10.1...4.10.2)
Expand Down
44 changes: 44 additions & 0 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8323,6 +8323,50 @@ describe('ParseGraphQLServer', () => {
expect(result.company.name).toEqual('imACompany2');
});

it('should support removing pointer on update', async () => {
const company = new Parse.Object('Company');
company.set('name', 'imACompany1');
await company.save();

const country = new Parse.Object('Country');
country.set('name', 'imACountry');
country.set('company', company);
await country.save();

await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear();

const {
data: {
updateCountry: { country: result },
},
} = await apolloClient.mutate({
mutation: gql`
mutation Update($id: ID!, $fields: UpdateCountryFieldsInput) {
updateCountry(input: { id: $id, fields: $fields }) {
country {
id
objectId
company {
id
objectId
name
}
}
}
}
`,
variables: {
id: country.id,
fields: {
company: { unlink: true },
},
},
});

expect(result.id).toBeDefined();
expect(result.company).toBeNull();
});

it_only_db('mongo')('should support relation and nested relation on create', async () => {
const company = new Parse.Object('Company');
company.set('name', 'imACompany1');
Expand Down
4 changes: 4 additions & 0 deletions src/GraphQL/loaders/parseClassTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ const load = (parseGraphQLSchema, parseClass, parseClassConfig: ?ParseGraphQLCla
description: `Link an existing object from ${graphQLClassName} class. You can use either the global or the object id.`,
type: GraphQLID,
},
unlink: {
description: `Unlink an existing object from ${graphQLClassName} class.`,
type: GraphQLBoolean,
},
};
if (isCreateEnabled) {
fields['createAndLink'] = {
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQL/transformers/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ const transformers = {
objectId,
};
}
if (value.unlink) {
return null;
}
},
};

Expand Down