You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This proposal suggests starting with a simpler definition of keys in GraphQL composite schemas by restricting keys to a single value. This approach aims to simplify the composite schema specification, the gateway-subgraph contract, and gateway implementations.
Proposal
Simplified Key Definition
Instead of complex key definitions, we propose using a single scalar value for keys:
typeFoo {
id: ID!@keyv: String
}
or
typeFooimplementsNode {
id: ID!v: String
}
Handling Complex Keys
For cases where the underlying model requires a more complex key, subgraph tooling can provide a helper method to create the composite-schemas key. An object-level key directive could be used as a convenience, interpreted only by the subgraph server:
This feature would be optional and could help subgraphs using the current spec to be grandfathered in.
Pros
Simpler Composite Schema Spec: Easier to understand and implement.
Simpler Gateway-Subgraph Contract: Reduces complexity in interactions. Easier troubleshooting.
Simpler Gateway Implementations: Less complex, potentially fewer bugs.
Batch Lookup: Simplifies batch lookup, eliminates need for GraphQL spec changes
Simple cases are easy. Complex cases are possible: Only subgraphs that desired complex keys need to take on any additional complexity
Cons
Server-Side Tooling: In order to have the same level of key flexibility and convenience, additional tooling is required.
Compatibility with Fed2: Subgraphs using complex keys with current Fed2 spec would need adaptation (though this could be done automatically through tooling).
The text was updated successfully, but these errors were encountered:
Copying from graphql/composite-schemas-wg#440
Introduction
This proposal suggests starting with a simpler definition of keys in GraphQL composite schemas by restricting keys to a single value. This approach aims to simplify the composite schema specification, the gateway-subgraph contract, and gateway implementations.
Proposal
Simplified Key Definition
Instead of complex key definitions, we propose using a single scalar value for keys:
or
Handling Complex Keys
For cases where the underlying model requires a more complex key, subgraph tooling can provide a helper method to create the composite-schemas key. An object-level key directive could be used as a convenience, interpreted only by the subgraph server:
The subgraph's GraphQL framework can automatically add the composite key:
This feature would be optional and could help subgraphs using the current spec to be grandfathered in.
Pros
Cons
The text was updated successfully, but these errors were encountered: