https://kotlinlang.org logo
Title
n

Neal Sanche

11/04/2021, 4:55 PM
I had recently updated to 3.0.0-beta01, and today updated my dependencies to 3.0.0-beta02 and nothing compiles anymore. I must be missing something. I get a lot of things like:
ApolloRequest<GetUserQuery.Data> but Query<TypeVariable(D)> was expected
and
Unresolved reference: hasErrors
and a bunch more like this. I'll keep looking.
m

mbonnin

11/04/2021, 5:06 PM
You've hit the fluent API changes:
val request = ApolloRequest.Builder(HeroQuery()).fetchPolicy(FetchPolicy.NetworkOnly).build()
val response = apolloClient.query(request)
becomes
val response = apolloClient.query(HeroQuery())
        .fetchPolicy(FetchPolicy.NetworkOnly)
        .execute()
n

Neal Sanche

11/04/2021, 5:06 PM
IDE caching issues. Cleared cache, and now I see there is an execute() method available that wasn't there before.
👍 1
Today I'm trying to get some changes through to our iOS guy. He hates the sealed classes because they come out in a very 'un-swift' way. And for some reason we are getting classes with underscores in them. Hoping that beta02 does something different in some of these cases.
m

mbonnin

11/04/2021, 5:20 PM
He hates the sealed classes because they come out in a very 'un-swift' way
I see... In that case, you can use
sealedClassesForEnumsMatching.set(emptyList())
to generate enums
This was intended to be removed but maybe we can keep it if it makes iOS cumbersome
And for some reason we are getting classes with underscores in them
Would you have an example?
n

Neal Sanche

11/04/2021, 5:22 PM
He's biting this sealed classes bullet for the sake of making less future work for us.
Yeah, for the _ classes, this started happening in beta01. Not sure if it happens in beta02 yet, just updating. But the class was called Money. We have a data class called Money in a different package, and one of our GraphQL queries also has one. So, the GraphQL code generator, I think, decided to add an underscore.
Or maybe this is a KMM thing happening. Not sure yet.
m

mbonnin

11/04/2021, 5:27 PM
The codegen adds very little
_
. IIRC, this only happens for kotlin keywords like
for
,
fun
,
object
, etc..
n

Neal Sanche

11/04/2021, 5:30 PM
Okay. I'll keep an eye out for that one. It's strange. Only seems to appear for the iOS target, so I'm suspecting Kotlin Multiplatform did it.
👍 1
m

mbonnin

11/04/2021, 5:31 PM
Let us know what you find!
n

Neal Sanche

11/04/2021, 5:31 PM
One final thing, as I go through this migration, what happened to the
queryCacheAndNetwork
function?
m

mbonnin

11/04/2021, 5:32 PM
It's
executeCacheAndNetwork
now
n

Neal Sanche

11/04/2021, 5:32 PM
Okay. Cool, thanks. Nice easy one.
m

mbonnin

11/04/2021, 5:32 PM
And it's on
ApolloQueryCall
Will add that to the Changelog, sorry we missed it
Sorry for all the changes, these are the final API tweaks before we go stable
n

Neal Sanche

11/04/2021, 5:33 PM
It makes more sense as part of the execution flow, I just didn't find it because it used to be on apolloClient.
m

mbonnin

11/04/2021, 5:34 PM
I think it's for the greater good as the chaining of cals makes it easier to configure requests but if you have anything you find awkward, it's still time to say it !
n

Neal Sanche

11/04/2021, 5:34 PM
The fluent APIs look nicer. 🙂
👍 1
b

bod

11/05/2021, 10:03 AM
Hi @Neal Sanche! Following your feedback (thanks!) we created this issue about the sealed classes generation. Please don't hesitate to comment on it (and share it to your iOS coworker 🙂) with any insights!
👍 2
a followup on this: we're trying to dig more on why sealed classes are not as nice to use as enums in Swift - in the issue we compared their usage and couldn't really conclude anything obvious - but obviously we're not Swift developers 😄 . If you have more info on this, it would be appreciated 🙂
n

Neal Sanche

11/10/2021, 9:46 PM
Yes. Sealed classes end up looking like Blah.ENUM_VALUE() in Swift. Whereas the enums end up looking like Blah.enumValue which is closer to what Swift enums look like. The fact that sealed classes have to be instantiated seems really odd. We ended up going that route, even though they look strange.
b

bod

11/11/2021, 1:37 PM
Thanks for the feedback! In my case, with the small example I played with (details are on the issue), it doesn't look like the sealed classes were renamed to all caps 🤔
A follow-up on this: we decided to go back to make the generation of enums the default behavior (and keep the ability to generate sealed classes as an opt-in - just like it was on 2.x). This will be effective in the next beta. Sorry for the disturbance and thanks again for the feedback! 🙂