apollographql / apollographql/federation

[Federation] invalid query is sent to federated service when original query contains aliases with fragments

Open
#397 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

When sending a query like

```graphql
query Test {
node(
nodeId: "WyJ0ZXN0IiwiMSJd"
) {
... on Device {
name
}
... on Catalog {
name: title
}
}
}
```

the following invalid query is forwarded by the gateway to the federated service:

```graphql
{ node(nodeId: "WyJ0ZXN0IiwiMSJdOGE0Il0=") { __typename ... on Device { name } ... on Catalog { name } } }
```

This should be

```graphql
{ node(nodeId: "WyJ0ZXN0IiwiMSJdOGE0Il0=") { __typename ... on Device { name } ... on Catalog { name: title } } }
```

So the information that a field `title` is being queried that should be _renamed_ to `name` is lost. Instead, the field `name` is being queried directly (which leads to an error in my case, since my type `Catalog` does not have a field `name`).

This seems to only happen if there is a second interface there (in this case: `Device`) that reads a field that really has the aliased name.

Contributor guide

Open the contributing guide

Research direction

The issue provides a GraphQL reproduction but names no source files or tests. Start by tracing how the federation gateway transforms aliases across the Device and Catalog inline fragments before forwarding a query. Add regression coverage and verify that the forwarded query preserves `name: title` instead of sending an invalid direct `name` field.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.