Skip to content

Variables dependency incompatible with Apollo Server 2 #12

@steverice

Description

@steverice

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions