apollographql / apollographql/federation

feat: composition warning on `@key` fieldsets that will never be used

Open
#2,702 0 comments 0 reactions 0 assignees View on GitHub
P3
Dominant language
TypeScript
Stars
727
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

It is possible to add `@key` selection set that will never be used. For example we can define a `@key` that expands another `@key`

```
type Foo @key(fields: "id") (fields: "id sku") {
id: ID!
sku: ID!
otherField: String
}
```

In the example above, query planner will never pick the 2nd composite key (`id sku`) as the entity can be identified by using simple key (`id`).

Related: https://github.com/apollographql/federation/issues/2695

Contributor guide

Open the contributing guide

Research direction

Start by tracing the composition validation path that processes @key selection sets, using the example in this issue and related issue #2695 as context. Add coverage for a key whose fields expand another key, and consider the work done when composition emits a warning that the broader key will never be selected.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.