apollographql / apollographql/federation
[Federation] Partial Queries - Discussion
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
Something I'd really like to see for federation is to support partial queries/results. As an example:
federated service 1's SDL might be:
```graphql
extend union ConfigTypes = OrgCommunicatonsConfig
type OrgCommunicatonsConfig {
canSendMessages: Boolean!,
canSendSMS: Boolean!
}
extend type Query {
getOrgConfig(): [ConfigTypes!] @partial
}
```
federated service 2's SDL might be:
```graphql
extend union ConfigTypes = OrgSecurityConfig
type OrgSecurityConfig {
setting1: String!,
setting2: String!
}
extend type Query {
getOrgConfig(): [ConfigTypes!] @partial
}
```
The resulting schema would be:
```graphql
union ConfigTypes = OrgSecurityConfig | OrgCommunicatonsConfig
type OrgSecurityConfig {
setting1: String!,
setting2: String!
}
type OrgCommunicatonsConfig {
canSendMessages: Boolean!,
canSendSMS: Boolean!
}
type Query {
getOrgConfig(): [ConfigTypes!]
}
```
The query executor would then forward any query to getOrgConfig to each service and then amalgamate the results so you can then do something like:
```graphql
query {
getOrgConfig() {
... on OrgSecurityConfig {
/// query fields
}
... on OrgCommunicatonsConfig {
/// query fields
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.