-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
Optimize VariableCoercer
#1856
Optimize VariableCoercer
#1856
Conversation
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.
Nice!
@@ -105,16 +105,18 @@ trait GraphQL[-R] { self => | |||
} | |||
typeToValidate = if (intro) introspectionRootType else rootType | |||
schemaToExecute = if (intro) introspectionRootSchema else schema | |||
validatedReq <- VariablesCoercer.coerceVariables(request, doc, typeToValidate, skipValidation) | |||
validatedVariables <- | |||
VariablesCoercer |
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 is super minor but how about extracting request.variables.getOrElse(Map.empty)
into a variable so that hopefully this fits in one line and stays easier to read?
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 was a bit wary of extracting them into a variable so we don't accidentally use them elsewhere but yeah the formatting was annoying me as well. Hopefully naming them unsafeVars
(unsafeVariables
didn't fit in a single line) will be clear enough that they're not to be used 😅
Seems that when we refactored the
Validator
to useZPure
we forgot(?) to do it with theVariableCoercer
. Reality is that in most cases the variables will be a small / shallow object so this doesn't really provide much performance benefits for most users, except perhaps in cases where the inputs are deeply nested JSON files.In this PR there are 2 different optimizations:
context
a by-name argument. This prevents us building the error context except when we need to fail the validationBenchmarking results
Before:
After: