Skip to content

Allow computing query complexity without variable values #1968

Description

@devin-ai-integration

We validate Apollo persisted operation manifests (CI gate for our mobile apps and web client) with DocumentValidator::validate(). A manifest contains only the operation text, so there are no variable values, but we would still like to enforce a complexity limit.

QueryComplexity cannot be used for that: it coerces the operation's variable definitions to evaluate @include/@skip (and field arguments for fields with a complexityFn), which fails for every operation declaring required variables.

Request: a supported way to compute the worst-case complexity without variable values, e.g. a flag or subclass hook where variable-conditional @include/@skip fields are counted as included and only literal @include(if: false) / @skip(if: true) are dropped.

Currently we subclass and override directiveExcludesField() to evaluate the directive arguments from the AST, but that relies on protected internals.

Related: #1730 (validation caching also has to special-case this rule).

Reported on behalf of @ruudk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions