Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional<T> has incorrect behavior when value for input argument does not exist in gql variables #6425

Closed
1 task done
tatarenkoigor opened this issue Aug 9, 2023 · 2 comments · Fixed by #6632
Closed
1 task done

Comments

@tatarenkoigor
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

When using the Optional type for input arguments, get incorrect behavior when there are no variable values ​​for optional arguments in the gql query.

mutation UpdateCource($id: UUID!, $name: String){
  updateCourse(input: {id:$id, name:$name}){
    id
  }
}

//variables
{
  "id":"08db8c2a-3775-ab62-ee9c-00d956620000"
}

I receive in resolver value for this argument {hasValue: true, value: null}
image

I expect {hasValue: false, value: null(unspecified)}.
image

Steps to reproduce

  1. Create input type
public class UpdateCource
{
    public Guid Id { get; set; }
    public Optional<string?> Name { get; set; }
}
  1. Run mutation
mutation UpdateCource($id: UUID!, $name: String){
  updateCourse(input: {id:$id, name:$name}){
    id
  }
}

//variables
{
  "id":"08db8c2a-3775-ab62-ee9c-00d956620000"
}
  1. Wrong result in Name argument
image
  1. Expected result in Name argument
image

Relevant log output

No response

Additional Context?

No response

Version

13.4.0

@Boooober
Copy link

Boooober commented Aug 9, 2023

Really struggling with this stuff on our project.
Workaround is to write different queries for setting and clearing fields, but this seems like overkill on the frontend side.

@michaelstaib
Copy link
Member

This is fixed with 13.6.0-rc.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants