Stylianos Gakis
07/16/2024, 10:09 AMnewestMessage: ChatMessage
.
In the business logic for this specific case all I care for is if it's null or not, not really interested in its internal state.
Right now in the .graphql file I specify:
newestMessage {
id
}
Or even
newestMessage {
__typename
}
but IDE plugin is hinting to me that I am not using it and it's greyed out.
I can't do newestMessage {}
either as that's an error.
I suppose there's no better way around this other than slapping a # noinspection ApolloUnusedField
on top of the id
field right?wasyl
07/16/2024, 10:10 AM__typename
ever be unused? đ¤ I think it's always fetched anywayStylianos Gakis
07/16/2024, 10:13 AMid
in this case is in fact the primary key too, aka in my extra.graphqls
I got extend interface ChatMessage @typePolicy(keyFields: "id")
, so from previous discussions here I understand that I will also fetch that one regardless of if I specify it or not. So both of them I suppose "technically" are never not asked for? Perhaps?
Doing some guess-work here, that's why I came here to ask in the first place đmbonnin
07/16/2024, 10:14 AMI think itâs always fetched anywayItâs always fetched and might end up being used by the normalized code but this is âunsafeâ access, i.e. itâs accessed at the JSON level, before itâs turned into typesafe Kotlin so the IDE doesnât know about those usages
mbonnin
07/16/2024, 10:15 AMalwaysActually, it âdependsâ, thereâs a parameter for that
Stylianos Gakis
07/16/2024, 10:16 AM__typename
or for the ËkeyField"?mbonnin
07/16/2024, 10:16 AMbod
07/16/2024, 10:18 AMShouldIt's automatically added to your queries - but if you explicitly query it, then I think it makes sense to check if you actually use it in your code?ever be unused? đ¤ I think it's always fetched anyway__typename
Stylianos Gakis
07/16/2024, 10:18 AMI think it makes sense to check if you actually use it in your codeYeah that's what I assumed here too. So perhaps the "# noinspection ApolloUnusedField" is the most reasonable approach for my use case?
bod
07/16/2024, 10:19 AMmbonnin
07/16/2024, 10:21 AMStylianos Gakis
07/16/2024, 10:22 AMForI see two interesting things here: ⢠"ifFragments" (deprecated) ⢠Default value: "ifFragments" The default is the deprecated one? And afaik there's no reference to this in the 3.x->4.x migration guide. is this something that we should optimally not leave as the deprecated option? I've never seen it before so I've never given it any thought before.(itâs called__typename
(kdoc))addTypename
mbonnin
07/16/2024, 10:24 AMmbonnin
07/16/2024, 10:27 AM"always"
because if an interface is introduced, a missing __typename
might introduce a cache miss
⢠other users want "ifPolymorphic"
because __typename
wastes bandwidth and looks not cool in the JSONStylianos Gakis
07/16/2024, 10:27 AMifAbstract
? đmbonnin
07/16/2024, 10:27 AMmbonnin
07/16/2024, 10:28 AMStylianos Gakis
07/16/2024, 10:29 AMmbonnin
07/16/2024, 10:30 AMitâs technically introducing some cache misses that could be avoided with âalwaysâ right?exactly, itâs suboptimal
Or are you worried that people will experience behavior changeThat. Changing that is a pain because it changes a lot of models. Typical use case is users creating their data classes manually in unit tests.
mbonnin
07/16/2024, 10:32 AMalways
will require everyone to pass a __typename
argument to every model, this is not fun. Especially for users that are not super familiar with GraphQL
, it feels very weird. Where does this __typename
come from? đ¤ˇmbonnin
07/16/2024, 10:43 AMAnd is the âalwaysâ that much heavier for it to not be a safe bet to use as a default?Thatâs also a concern actually. Iâm not 100% about the âheavinessâ of it. With gzip it should compress quite well but itâs still surprising to a non-negligeable portion of users and creates friction. See https://github.com/apollographql/apollo-kotlin/issues/1018 for an example