-
Notifications
You must be signed in to change notification settings - Fork 1.2k
grapqql/executor: set variables on operation context after validation … #3952
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
base: master
Are you sure you want to change the base?
Conversation
a8m
left a comment
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.
Looks good to me.
@StevenACoffman, any objection to merging this?
|
cc @giautm |
a0ab1f3 to
a5e8230
Compare
a5e8230 to
7c27f79
Compare
|
It looks like there are currently test failures: |
| gqlErr, ok := err.(*gqlerror.Error) | ||
| if ok { | ||
| errcode.Set(gqlErr, errcode.ValidationFailed) | ||
| opCtx.Variables = params.Variables |
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 dont like the idea of having invalid variable on the execution context, it should Only and only accept valid variable there - thats the point of validation.
I prefer have the raw input on the gqlError instead.
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.
Cc @noamcattan / @a8m
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 feel similarly. Generally, a function returns a value OR an error, but not both.
Otherwise, it seems to be splintered failure mode. If we really need to carry around invalid variables for some contextual error reporting, then we could make a custom error type for that purpose.
|
@noamcattan I think this is extremely valuable, and I would really like you to continue to work on this. However, I think it would be better to create and return a custom error with the values you need to access. |
|
@StevenACoffman sure thing, only that now I don't have an ETA for this. I'll ping you when I'll have an update |
…error
Looks like this is relevant for the following issues:
#3223
#2669
I realized that when the variable validation failes, the variables are not set on the operation context. Since I use the operation context for logging and tracing errors in an extension, this makes it really hard to debug issues, because I lack visibility on what's was passed by the client.
Another workaround I found is to inject the variables in a
OperationParameterMutatorextension, but this feels like a more correct way.Thanks in advance for the review!
I have: