-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix error raised in deserialization of resolver aliased parameters. #130
Conversation
Thank you for having spotted this tricky bug. Because it's not enough documented in the code, let me explain the reason of this conditional
Concerning your test, for this kind of issue, i would prefer an "integration test", calling
|
apischema/graphql/resolvers.py
Outdated
@@ -269,7 +269,9 @@ def resolve(__self, __info, **kwargs): | |||
errors: Dict[str, ValidationError] = {} | |||
for alias, param_name, deserializer, opt_param, required in parameters: | |||
if alias in kwargs: | |||
if not opt_param and kwargs[param_name] is None: | |||
# If this parameter was required but not supplied we can ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not exact (see my comment in the PR)
The parameter is not required but its default is not serializable, so it ends up with an optional parameter, with null
as an authorized value. In that case, it should be ignored to ensure using the true default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, because the parameter is in kwargs
, that means it has been explicitely supplied by the GraphQL query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've redone the comment, is that closer to what you mean? Re: kwargs
, do you mean as opposed to just having a default value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is perfect.
About kwargs
, your previous comment was not exact, because kwargs[alias]
being None
means that the argument *was supplied in the query; if it was not supplied, kwargs
would not contains alias
.
Thanks for taking a look. I agree RE: the tests, I've moved them. I'm also happy to include the correction to |
Concerning |
Fix aliased resolver arguments being looked up by original value when checking for parameter requirement. Unsure if the routine needs to check for both the alias and original parameter name.