apollographql / apollographql/federation

federation spec: types with all fields marked @external

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

Description

Suppose you have some service which needs to return a type which it does not implement nor extend. For example:
```graphql
extend type Foo @key(fields: "id") {
id: ID @external
}

type Bar {
relatedFoo: Foo
}
```

In this case, the only thing this service ever needs to do with `Foo` is to return a Foo containing only an ID.

However, the [spec says](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/#resolve-requests-for-entities):
> To implement the `_Entity` union, each type annotated with `@key` should be added to the `_Entity` union

Thus `Foo` does have to get added to `_Entity`, which means in principle the service is supposed to able to handle an `_entities` query for one. But I don't see why: we should never be asked to look up a `Foo` by key, since we only return them.

(A special cases is where there's another field `Foo.name @external`, say, and `relatedFoo` has `@provides(fields: "name")`. But the result is the same: we should never be asked to look up a Foo, even though we may return some fields of one.)

So: can we exclude types with all fields `@external` from `_Entity`? Or is there some way such entities can be requested?

(For context, this came up in `gqlgen`, a Go GraphQL server with federation support: https://github.com/99designs/gqlgen/issues/1076.)

Contributor guide

Open the contributing guide

Research direction

Start with the federation specification's “Resolve requests for entities” section and compare it with the gqlgen issue linked in the report. Determine whether a type whose fields are all @external can be omitted from _Entity or can otherwise be requested; done means the specification question has a clear, documented resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.