async-graphql: Allow to differentiate between null and undefined
Let’s say I have a task object with an optional deadline
struct Task {
text: String,
deadline: Option<DateTime<Utc>>
}
Currently with my JS server I can update the task with some mutation:
mutation m1($id: ID!, $text: String!, $deadline: DateTime) {
UpdateTask(id: $id, text: $text, deadline: $deadline ) {
id
text
deadline
}
}
The gql variable $deadline
can takes 3 different types of values:
- a Date, which update the deadline
undefined
, which do not modify the deadlinenull
, which clears the deadline
I can’t find a way to reproduce this with async_graphql, does anyone have an idea on how to handle this?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (6 by maintainers)
I finished this. 😁
https://github.com/async-graphql/async-graphql/blob/8afe5427e109f9987ed9ed0ab40024777e461165/tests/maybe_undefined.rs#L4
It’s a big change, but it’s not a breaking change.
Just to be clear:
None
->undefined
Some(None)
->null
Some(Some(x))
->x
Correct?
How would this look in graphql? Just an optional
DateTime
?