Skip to content

When multiple operations are passed in query, wrong operation is taken and the operationName is ignored #217

@upcFrost

Description

@upcFrost

When working with multiple operations in one query (happens a lot when using browser-based gql clients for testing), the gateway responds with error adding scrub fields: could not find field for point. After a closer look, the targetSelection in the generateScrubFieldsWalk method contains only the first operation out of all present in the query.

The spec suggests that the operation should be taken by name: https://spec.graphql.org/October2021/#sec-Executing-Requests

The culprit is most likely the array selector here:

gateway/plan.go

Line 115 in 0ac544a

flatSelection, err := graphql.ApplyFragments(parsedQuery.Operations[0].SelectionSet, parsedQuery.Fragments)

the operationName should be passed in the PlanningContext in GetPlans and then used to select the correct operation

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