async-graphql
async-graphql copied to clipboard
Additional control over resolver arguments
Description of the feature
I'd like to be able to tell if a resolver argument was passed or explicitly set to null.
Code example (if possible)
async fn update(&self, foo: Parameter<i32>, bar: Parameter<Input>)
Now this Parameter would be equivalent to Option, but for the sake of clarity it's a different enum.
This means that in the case of Parameter<Option<T>> I can discern between a parameter not being passed, a null, and a value.
This might be possible to handle by abusing default but I'm not entirely sure about the semantics in that case, and a Parameter type would make that clearer.
I need this to implement decent partial updates to objects.
You should have a look at MaybeUndefined<T>. You can see more information about how it works here.
That's exactly what I wanted :panda_face:
It also took me a while to find when I ran into the same use case as you have.
@sunli829 Is MaybeUndefined<T> included in the async-graphql book website? Because if it is missing from the website I can do a PR to add a section about it so it is easier to find.
@oscartbeaumont I am so happy that you can help me add this to the book. 🙂
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.