You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to enable the QueryComplexity rule and noticing that when the rule executes, it attempts to parse the values of the inputs multiple times for each Field definition.
The issue I am running into is that I have a custom scalar type that does some validation when parseValue() or parseLiteral() are called and log when it fails validation, and this validation process seems to be running (hundreds) multiple times, while I would expect that code to run at most once while the QueryComplexity is traversing through the schema. This ends up generating hundreds of error log lines when the custom scalar type fails validation, but also, it seems sub-optimal in that the rule attempts to extract/parse the same values from the input over and over.
Is this intentional behavior? Should my custom scalar type memoize the return value of parseValue() and prevent triggering the validation repeatedly?
The text was updated successfully, but these errors were encountered:
I am surprised this hasn't been brought up before as it seems something that would impact performance on a large graph and that's why I thought maybe I was doing something wrong.
It sounds like memoization would help to prevent calling Values::getVariableValues() multiple times, but buildFieldArguments() would still need to be called multiple times, as it is attempting to extract the arguments for a specific field/node, no?
I am trying to enable the QueryComplexity rule and noticing that when the rule executes, it attempts to parse the values of the inputs multiple times for each Field definition.
The issue I am running into is that I have a custom scalar type that does some validation when parseValue() or parseLiteral() are called and log when it fails validation, and this validation process seems to be running (hundreds) multiple times, while I would expect that code to run at most once while the QueryComplexity is traversing through the schema. This ends up generating hundreds of error log lines when the custom scalar type fails validation, but also, it seems sub-optimal in that the rule attempts to extract/parse the same values from the input over and over.
Is this intentional behavior? Should my custom scalar type memoize the return value of parseValue() and prevent triggering the validation repeatedly?
The text was updated successfully, but these errors were encountered: