apollographql / apollographql/federation

[Federation] Partial Queries - Discussion

Open
#347 1 comment 3 reactions 1 assignee Claimed by @jbaxleyiii View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.