Stylianos Gakis
04/19/2024, 7:50 AM@null
directive?
We have a field which was wrongly marked as non-null on the schema, but really it should just be null for various reasons. One way is to deprecate that one and add a second one, and keep the old one around for old clients so that we make a forwards compatible change. That works fine.
I was thinking could we go the other way around, and mark it as nullable on our clients for now, in preparation for the future. Then in X time forward, we can go and make the breaking change in the backend, turning it nullable, and by that time we will make sure that we have kill-switched all old clients, something we do anyway on some intervals for other reasons which are unrelated to this, but would help in scenarios like this.
I can for now go on and edit the final result of the ApolloDownloadSchemaTask
task, which would work too, but I am just curious if there was any previous discussion on this idea in general that I would find interesting to read.mbonnin
04/19/2024, 7:51 AMwas wrongly marked as non-null on the schemaThat's interesting, it's usually the other way around!
mbonnin
04/19/2024, 7:52 AMcould we go the other way around, and mark it as nullable on our clients for now, in preparation for the futureLooks like that would work.
mbonnin
04/19/2024, 7:53 AMI can for now go on and edit the final result of theI would do that in the short term. You can even automate this with some GradletaskApolloDownloadSchemaTask
mbonnin
04/19/2024, 7:53 AMmbonnin
04/19/2024, 7:54 AMmbonnin
04/19/2024, 7:55 AMmbonnin
04/19/2024, 7:56 AMmbonnin
04/19/2024, 7:56 AMStylianos Gakis
04/19/2024, 8:07 AMI would do that in the short term. You can even automate this with some GradleYeap, I got this task https://github.com/HedvigInsurance/android/blob/6092dc0c00eec31c8fb0b12661e7b99ffe[…]uild-logic/convention/src/main/kotlin/ApolloConventionPlugin.kt locked and loaded for such scenarios. I added it with your help quite some time ago. I may just put it there indeed.
… but in larger orgs …That is indeed true. Normally I would simply suggest the normal cycle of deprecation which I described above. That’s fool-proof, and then through using our metrics from apollo-studio we could easily determine when the right time for us to remove the deprecated field is. I was only thinking this here because we know who are 2 clients are, this is a very rarely used field, and I was also just being curious 😄
There is a whole GraphQL sub-working group dedicated to nullabilityVery interesting, thanks for sharing it. I think it’s not a very strong need that we have, and honestly in almost all scenarios doing that as a means to migrating away from the non-null field would more or less be strictly worse (besides less code) from the method I describe above. So if that would be the only use case I honestly don’t think I would push at all for something like it to be added. Again, mostly curiosity made me ask this 😄
mbonnin
04/19/2024, 8:50 AMmbonnin
04/19/2024, 8:52 AMStylianos Gakis
04/19/2024, 8:59 AM