-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for type to be omitted when calculating Cache keys #102
Comments
(I've transferred the ticket because new cache features will happen here.) Thanks for this, this is interesting! For your immediate use case, you may provide your own Also, I'm wondering if there's a way to make the builtin More thoughts about your proposal: do we need the distinction between service and universal? |
Not for my use case, but I thought it would be a good idea to nail down this distinction in case a service becomes part of a federated graph. The term "global" could refer to either |
I want it for the day we have a Global supergraph 😄 Then I can cache my GitHub pull requests and Shopify inventory in the same cache 🚀 (probably not until a couple more decades so let's say I support |
Obviously I'm not attached to immediately adding |
Use case
Given an endpoint that returns an interface type, it's currently not possible to set a fieldPolicy that will resolve the various implementation types.
I'm trying to use the
node
field to get a variety of types that have most fields in common. However, since those types are cached using their full type name, it isn't possible to retrieve the object from cache using thenode
field because only the Node interface is known.Describe the solution you'd like
Inspired by the rejected RFC apollographql/apollo-ios-dev#549, I want to suggest
@typePolicy
and@fieldPolicy
gain a new field namedkeyScope
, with one of the following possible values:TYPE
: The identifier is unique for the type, e.g. an auto-incrementing column from a database table.SERVICE
: The identifier is unique across the current GraphQL Service, e.g. a type name combined with an auto-increnting column.UNIVERSAL
: The identifier is unique across all GraphQL services, e.g. UUIDs generated through RFC 9562. Exact serialization details are unspecified, as long as all UUID information is present. Appending more information is allowed.TYPE
is the default. If the scope is notTYPE
, cache keys should not contain the type name but only use the actual id as a cache key (possibly with a constant prefix).The GraphQL best practice known as Global Object Identification requires that all
id
s are unique across the service. This is also a required part of the Relay spec.The text was updated successfully, but these errors were encountered: