Eduard Boloș
04/04/2025, 10:42 AM@optional
directive when used on a non-nullable object. In the generated model, the respective field becomes nullable, but in the *Selections
object, the annotated field's type is still marked with .notNull()
, making it a CompiledNotNullType
. Is that on purpose?
Context: we do some shenanigans in our CacheResolver
to avoid some cache misses by returning null instead of nullable fields, and we were trying to do this for a field that is marked not null in the schema generated from the backend, so that we can successfully execute the query even if the user is offline (e.g. with NetworkFirst
).bod
04/04/2025, 12:27 PMEduard Boloș
04/04/2025, 1:24 PMbod
04/04/2025, 1:27 PMbod
04/04/2025, 1:27 PMbod
04/04/2025, 1:31 PM@optional
.Eduard Boloș
04/04/2025, 1:37 PMMaybe you will have more luck patching your schema to make the field in question nullable, rather than usingYeah, ultimately this is what we are going to do, but it has a slightly longer turnaround, and semantically the field will never be null from the server, we just make it nullable to hack our own partial response mechanism 😄.@optional
Eduard Boloș
04/04/2025, 1:39 PMnotNull
be something that should happen when using the @optional
directive? (aka, should I open a bug ticket on GH? 😄)bod
04/04/2025, 1:41 PMwould making the selection field also non-I think it's debatable because the type itself is still non nullable in the schema - it's the selection field that is marked (and generated) non null. But maybe it would still make sense - so an issue would be welcome 🙂be something that should happennotNull
bod
04/04/2025, 1:43 PMbod
04/04/2025, 1:45 PMnull
wouldn't it make more sense to have an actual value? That would avoid this whole problem 🙂 (But I guess this would be less easy to build something generic)Eduard Boloș
04/04/2025, 4:15 PMCacheResolver
-based one 😅
I will open an issue on Monday, cheers!Eduard Boloș
04/07/2025, 12:56 PM