-
Notifications
You must be signed in to change notification settings - Fork 673
Add key fields to selections even when they're already selected with an alias #6503
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
base: main
Are you sure you want to change the base?
Conversation
|
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.
Could we avoid duplicating the field? I think we have everything for that in CacheKeyGeneratorContext.field.selections
?
Fragments make it a bit more complicated (because we don't have the full schema at runtime so a given field may be key in one fragment but not in the other and we probaby wouldn't know which one...).
@@ -94,7 +94,7 @@ private fun List<GQLSelection>.addRequiredFields( | |||
requiredFieldNames.add("__typename") | |||
} | |||
|
|||
val fieldNames = parentFields + selectionSet.filterIsInstance<GQLField>().map { it.name }.toSet() | |||
val fieldNames = parentFields + selectionSet.filterIsInstance<GQLField>().map { it.alias ?: it.name }.toSet() |
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.
val fieldNames = parentFields + selectionSet.filterIsInstance<GQLField>().map { it.alias ?: it.name }.toSet() | |
val fieldNames = parentFields + selectionSet.filterIsInstance<GQLField>().map { it.responseName() }.toSet() |
Another option is to codegen the key responseNames in Note: just realized that the keyfields are added after validation so we're potentially sending invalid queries to the server 😬 |
Ah yes we could look for the field's name, and fallback to its alias(es). But I actually don't follow your caveat about fragments, do you have an example? |
union Stuff = Book | Banana
interface Product {
# ...
}
type Book @typePolicy(keyFields: "isbn") implements Product {
isbn: String!
# ...
}
query GetStuff {
stuff {
... on Product {
... on Book {
identifier: isbn
}
}
}
} Walking Ultimately, it probably requires that we implement collectFields() inside the |
No description provided.