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 deadline
  • null, 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)

Most upvoted comments

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?