-
Notifications
You must be signed in to change notification settings - Fork 60
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
feature: Emit Identifiable conformance on SelectionSets #584
base: main
Are you sure you want to change the base?
Conversation
👷 Deploy request for eclectic-pie-88a2ba pending review.Visit the deploys page to approve it
|
👷 Deploy request for apollo-ios-docc pending review.Visit the deploys page to approve it
|
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 2f9d869c04823e5db25d5510 |
I think it would be beneficial to include a test that has
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One formatting suggestion.
|
||
/// Indicates if the parent type has a single keyField named `id`. | ||
public var isIdentifiable: Bool { | ||
guard direct?.fields ["id"] ?? merged.fields["id"] != nil else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guard direct?.fields ["id"] ?? merged.fields["id"] != nil else { | |
guard direct?.fields["id"] ?? merged.fields["id"] != nil else { |
This is a rework of #548, except this time it will only emit a conformance if the
keyFields
is set to exactly["id"]
(instead of assuming the presence of anid
field is enough).If a type has a field named
id
it is actually impossible to override the behavior ofIdentifiable
, so I believe there is no situation in which an automatic conformance to Identifiable isn't desirable.This PR will not generate a getter named
id
(as was proposed earlier), so there won't be an unexpected field namedid
in any case.