-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow update mutations to pass null for optional relations (#1002)
This makes it possible to reset an optional relation with an update mutation: ```graphql mutation resetEvent { updateNotification(id: 1, data: {title: "N1-updated", event: null}) { id event } } ```
- Loading branch information
Showing
4 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Notification has an optional event | ||
@postgres | ||
module NotificationDatabase { | ||
@access(true) | ||
type Notification { | ||
@pk id: Int = autoIncrement() | ||
title: String | ||
description: String | ||
event: Event? | ||
} | ||
|
||
@access(true) | ||
type Event { | ||
@pk id: Int = autoIncrement() | ||
title: String | ||
notifications: Set<Notification>? | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
stages: | ||
- operation: | | ||
mutation { | ||
e1: createEvent(data: {title: "E1"}) { | ||
id @bind(name: "e1Id") | ||
} | ||
e2: createEvent(data: {title: "E2"}) { | ||
id @bind(name: "e2Id") | ||
} | ||
} | ||
- operation: | | ||
mutation($e1Id: Int!, $e2Id: Int!) { | ||
n1: createNotification(data: {title: "N1", description: "N1-desc", event: {id: $e1Id}}) { | ||
id @bind(name: "n1id") | ||
} | ||
n2: createNotification(data: {title: "N2", description: "N2-desc", event: {id: $e2Id}}) { | ||
id @bind(name: "n2id") | ||
} | ||
} | ||
variable: | | ||
{ | ||
"e1Id": $.e1Id, | ||
"e2Id": $.e2Id | ||
} |
52 changes: 52 additions & 0 deletions
52
integration-tests/optional-relation/tests/reset-relation.exotest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
stages: | ||
- operation: | | ||
mutation resetEvent($eId: Int!) { | ||
updateNotification(id: $eId, data: {title: "N1-updated", event: null}) { | ||
id | ||
event | ||
} | ||
} | ||
variable: | | ||
{ | ||
"eId": $.e1Id, | ||
} | ||
response: | | ||
{ | ||
"data": { | ||
"updateNotification": { | ||
"id": 1, | ||
"event": null | ||
} | ||
} | ||
} | ||
- operation: | | ||
query { | ||
notifications @unordered { | ||
id | ||
title | ||
event { | ||
id | ||
title | ||
} | ||
} | ||
} | ||
response: | | ||
{ | ||
"data": { | ||
"notifications": [ | ||
{ | ||
"id": $.n1id, | ||
"title": "N1-updated", | ||
"event": null | ||
}, | ||
{ | ||
"id": $.n2id, | ||
"title": "N2", | ||
"event": { | ||
"id": $.e2Id, | ||
"title": "E2" | ||
} | ||
} | ||
] | ||
} | ||
} |