apollographql / apollographql/federation
Ability to mark a field as always being able to be provided
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
In GraphQL services it is often the case that some fields are always able to be resolvable, no matter how they are traversed to.
This means that everytime such a field is added, a lot of `@provides` directive in the schema need to be updated.
In particular, in the case where all of the fields in a service are implemented in this way it means that there is a potentially large amount of code duplication where all the fields of all types are enumerated repeatedly. Keeping all of these in sync is a hard problem in this case.
I propose a directive could be added that could be applied on the field itself or an argument could be added to the `@external` directive itself. For example:
```graphql
extend type Example @key(fields: "id") {
id: ID! @external
example: String! @external(alwaysProvided: true)
}
```
Internally, this could be automatically unpacked to every reference to the `Example` type when the schema is initially parsed, whick might makes it easier to implement as there'd be no changes required for query planning.
Contributor guide
Research direction
Start by reading the schema-parsing behavior for @external and @provides, then examine how references to an extended type are represented before query planning. Compare a field-level directive with an @external argument and define the schema and planning behavior that would demonstrate the feature is complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100