-
Notifications
You must be signed in to change notification settings - Fork 2k
consider memoizing getArgumentValues #383
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
Comments
Sounds like there's an opportunity for memoization here. |
Isn't the GraphQL query converted into an AST? And aren't all literals parsed at that time? This would be necessary for error-checking. I'm just wondering why the parsed literal isn't already in memory by the time |
graphql-js/src/execution/execute.ts Lines 520 to 525 in 2562ce0
Just looking at it quickly, you could use memoize3, but it should be possible to use something like memoize2 as the fieldDef is always the same for that field node. |
Maybe I don't understand something, but I didn't think it would be necessary for
GraphQLScalarType.parseLiteral
to be called every time a field argument is resolved.e.g., given this GraphQL query:
And this field:
And this custom type:
The
asOf
argument is parsed every timeresolve
is called -- i.e., 10 times for this one query because I've limited the results to 10. It so happens that myparseDate
function is slow, this is kind of painful. I can memoize it on my end, but I didn't think that should be necessary.Why aren't all the literals parsed just once when the query is received?
The text was updated successfully, but these errors were encountered: