federation icon indicating copy to clipboard operation
federation copied to clipboard

[Federation] Partial Queries - Discussion

Open eyn opened this issue 5 years ago • 1 comments

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:

extend union ConfigTypes = OrgCommunicatonsConfig

type OrgCommunicatonsConfig {
    canSendMessages: Boolean!,
    canSendSMS: Boolean!
}

extend type Query {
    getOrgConfig(): [ConfigTypes!] @partial
}

federated service 2's SDL might be:

extend union ConfigTypes = OrgSecurityConfig

type OrgSecurityConfig {
    setting1: String!,
    setting2: String!
}

extend type Query {
    getOrgConfig(): [ConfigTypes!] @partial
}

The resulting schema would be:

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:

query {
    getOrgConfig() {
        ... on OrgSecurityConfig {
         /// query fields
       }
       ... on OrgCommunicatonsConfig {
         /// query fields
       }
    }
} 

eyn avatar Nov 05 '19 15:11 eyn

I'm looking for something just like this. Did this ever get implemented?

askurat avatar Aug 08 '22 17:08 askurat