apollographql / apollographql/federation
Docs for Entities say __typename is required in reference but in practice it is not
- Dominant language
- TypeScript
- Stars
- 727
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
The docs say:
> A representation **requires** only an explicit __typename definition and values for the entity's primary key fields.
and show the code:
```javascript
{
Review: {
product(review) {
return { __typename: "Product", upc: review.upc };
}
}
}
```
under the Resolving header: https://www.apollographql.com/docs/federation/entities/#resolving.
However, if you give the product field the type `Product` in the type defs, it will resolve with just upc, like so:
```javascript
{
Review: {
product(review) {
return { upc: review.upc };
}
}
}
```
Should the docs be updated to no longer require `__typename` in the reference? Something like:
> A representation requires only the values for the entity's primary key fields.
Contributor guide
Research direction
Start at the Resolving section of the federation entities documentation linked in the issue and compare its statement about __typename with the shown resolver examples. Verify the documented behavior against the Product-typed field case described, then update the wording if appropriate. Done means the reference accurately describes the required entity representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100