Skip to content

Commit addfcfa

Browse files
authored
Remove SELECTION scope and change overriding behavior
1 parent fcb15f0 commit addfcfa

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

apollo-ios/Design/swift-identifiable.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ A concept of identity is required to allow response objects to be cached. The va
1414

1515
The directive is defined as:
1616
```graphql
17-
directive @identity(scope: IdentityScope = SELECTION) on FIELD | FIELD_DEFINITION
17+
directive @identity(scope: IdentityScope = TYPE) on FIELD | FIELD_DEFINITION
1818

1919
enum IdentityScope {
20-
SELECTION
2120
TYPE
2221
SERVICE
2322
GLOBAL
@@ -30,10 +29,9 @@ This directive MUST be used on a field with a non-nullable scalar type. Other ty
3029

3130
The directive can have a parameter indicating the scope of the identity. They are ordered from _narrowest_ to _widest_:
3231

33-
1. `SELECTION`: The identifier is only unique within the current list. Identifiers may be reused between different objects with the same typename.
34-
2. `TYPE`: The identifier is unique for the type, e.g. an auto-incrementing column from a database table.
35-
3. `SERVICE`: The identifier is unique across the current GraphQL Service.
36-
4. `GLOBAL`: The identifier is unique across all GraphQL services. This can be used by identifiers generated according to [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122) or [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562) (also known as Universally Unique IDentifiers or UUIDs).
32+
1. `TYPE`: The identifier is unique for the type, e.g. an auto-incrementing column from a database table.
33+
2. `SERVICE`: The identifier is unique across the current GraphQL Service.
34+
3. `GLOBAL`: The identifier is unique across all GraphQL services. This can be used by identifiers generated according to [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122) or [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562) (also known as Universally Unique IDentifiers or UUIDs).
3735

3836
## Usage in types
3937

@@ -73,7 +71,7 @@ query GetAllAnimals {
7371
}
7472
```
7573

76-
It is allowed for a query and a type to both use the directive to describe the same field. If the schema and client define different scopes for the same field, the widest option is used. This allows client authors to widen the scope if required.
74+
It is allowed for a query and a type to both use the directive to describe the same field. If the client and schema use different scopes for the same field, the scope defined by the schema is used. Clients SHOULD NOT define a wider scope than declared by the schema. Codegen should emit a warning in this case.
7775

7876
If the server defines a field as an identity, a query SHOULD NOT choose another field. A query MUST NOT use the directive on more than one field in the same selection (unless they are in differently nested objects).
7977

@@ -103,7 +101,7 @@ In this case, a conformance to Identifiable SHOULD NOT be generated. Codegen sho
103101

104102
## Caching behavior
105103

106-
A scope of `SELECTION` does not allow the identifier to be used as a caching key. Clients MAY use other mechanisms to determine if and how to cache the object.
104+
If no `@identity` directive is present, clients MAY use other mechanisms to determine if and how to cache the object.
107105

108106
An identifier with scope `TYPE` can be combined with the `__typename` field to generate a caching key that's unique for the GraphQL Service.
109107

@@ -117,7 +115,7 @@ The code generator could be updated to always emit a conformance to Identifiable
117115

118116
## Apollo Kotlin's @typePolicy directive
119117

120-
Apollo Kotlin has [custom directives](https://www.apollographql.com/docs/kotlin/caching/declarative-ids) that allows for client authors to specify the caching key though pure GraphQL:
118+
Apollo Kotlin has [custom directives](https://www.apollographql.com/docs/kotlin/caching/declarative-ids) that allows for client authors to specify the caching key through pure GraphQL:
121119

122120
```graphql
123121
extend type Book @typePolicy(keyFields: "id")

0 commit comments

Comments
 (0)