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

Property variable_values from class Info returning wrong information #3460

Open
ShtykovaAA opened this issue Apr 19, 2024 · 12 comments
Open
Labels
bug Something isn't working

Comments

@ShtykovaAA
Copy link

ShtykovaAA commented Apr 19, 2024

Hi!

I have an example, where I want to update some fields in my entity, here is my example https://play.strawberry.rocks/?gist=67964a59e64b5c3c6bdce477826db9f5

So details: I want to update some fields from frontend, I want to know what exactly fields were sent to backend, but function return all input object with default None value.

It's important because some fields could be null in database.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@ShtykovaAA ShtykovaAA added the bug Something isn't working label Apr 19, 2024
@patrick91
Copy link
Member

@ShtykovaAA you can do that using UNSET: https://play.strawberry.rocks/?gist=a70bc1aa74d5d04a6ceea1be6a7b7575

https://strawberry.rocks/docs/types/input-types#defining-input-types

@ShtykovaAA
Copy link
Author

@patrick91 it works! thank you!

@ShtykovaAA
Copy link
Author

@patrick91 sorry I checked that it doesn't work for @strawberry.experimental.pydantic.input(PydanticModel) and I want to fix it, do I need another conversation?

@patrick91 patrick91 reopened this Apr 19, 2024
@patrick91
Copy link
Member

@ShtykovaAA cab you make an example in the playground? I think pydantic should work there ☺️

@ShtykovaAA
Copy link
Author

@ShtykovaAA
Copy link
Author

@patrick91 I found the place of mistake: https://github.com/graphql-python/graphql-core/blob/main/src/graphql/utilities/coerce_input_value.py#L102
So if I'm using strawberry.input the default value is Undefined, but than I'm using @strawberry.experimental.pydantic.input(PydanticModel) the default value is None...

@patrick91
Copy link
Member

@ShtykovaAA thanks for checking! I might have some time to fix this during the weekend, or feel free to send a PR if you find a way to fix it!

@ShtykovaAA
Copy link
Author

@patrick91 I'm newbie but I really want to take a chance

I think we need to check this condition https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/experimental/pydantic/object_type.py#L76 because it means that we are overwriting our strawberry.input by PydanticField and that's why the default value is None, but not UNSET.

what do you think about it? I think it's a big change in project, but I think that it's supposed to be like that

@patrick91
Copy link
Member

@ShtykovaAA I'm not too sure! Feel free to try and send a draft PR, we should have enough test to make sure this becomes a valid change 😊

@ShtykovaAA
Copy link
Author

@patrick91 hi! I added draft pr, tell me if there will be time to look/discuss my changes?

@patrick91
Copy link
Member

@ShtykovaAA can you link the PR here? 😊

@ShtykovaAA
Copy link
Author

@patrick91 yes, sure #3469

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants