Eduard Boloș
04/29/2025, 10:34 AMid
field is not included for objects that have such a field? Or do you think that this is something that could be part of the Apollo tooling? We are using id
as the cache key in our CacheKeyGenerator
implementation, and it would be useful to have such a check so that people's queries don't mess up the cache by mistake (we had several bugs and crashes due to this 😅)mbonnin
04/29/2025, 10:42 AMmbonnin
04/29/2025, 10:43 AMApolloCompilerPlugin.documentTransform
that is more geared towards modifying the document (adding the "id" field automatically) but I guess you could also just return the document "as-is" and just run checksmbonnin
04/29/2025, 10:44 AMNode
base interface?mbonnin
04/29/2025, 10:46 AMextend interface Node {
id: ID! @keyField
}
which should work automatically (event though there might be edge cases but I'm unclear about that part)bod
04/29/2025, 11:46 AMEduard Boloș
04/29/2025, 12:31 PMThere isCool, we already have a compiler plugin to make generated sealed classes for GQL enums parcelable 😄 Currently I implemented the check in a hacky manner in thethat is more geared towards modifying the document (adding the "id" field automatically) but I guess you could also just return the document "as-is" and just run checksApolloCompilerPlugin.documentTransform
CacheKeyGenerator
by using some reflection, so this sounds like a better solution to look into, thanks!
Out of curiosity, is your field always named "id" and if yes, is there any reason your backend team doesn't use Relay global identification using aYes, it's always named "id" afaik. No idea why we don't use abase interface?Node
Node
interface for all objects, maybe due to lazyness? But if we did, with the id
field being annotated as @keyField
, would that make it being pulled into the query automatically by Apollo with this change you are discussing?mbonnin
04/29/2025, 12:33 PMwith theYep, that's the general planfield being annotated asid
, would that make it being pulled into the query automatically by Apollo with this change you are discussing?@keyField
Eduard Boloș
04/29/2025, 12:54 PMmbonnin
04/29/2025, 1:25 PMwasyl
04/29/2025, 2:24 PMid
is fetched if a type has it, you can also use https://github.com/graphql-hive/graphql-eslint. It has also some other checks like codestyle, not fetching duplicate fields, not having unused fragments etc.Eduard Boloș
04/29/2025, 4:54 PMmbonnin
04/29/2025, 4:59 PMmbonnin
04/29/2025, 5:00 PMwasyl
04/29/2025, 5:06 PM