-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Currently, the validation rule requires providing the variables object from the request because
This is needed because the variables are not available in the visitor of the graphql-js library.
Unfortunately, version 2 of Apollo Server no longer allows dynamic configuration of all of its server options per-request, but rather only the context. validationRules must be provided when the server is initialized and not within the context of the middleware. Therefore, all that each validation rule has access to is the ValidationContext and there's no built-in way to inject the request variables.
I am reasonably certain that this is an intentional change.
It seems possible to remove graphql-cost-analysis's dependence on the full variables object, given that the ValidationContext provides information about variable usages and also about field arguments.
Is this feasible?