I had recently updated to 3.0.0-beta01, and today ...
# apollo-kotlin
n
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
You've hit the fluent API changes:
Copy code
val request = ApolloRequest.Builder(HeroQuery()).fetchPolicy(FetchPolicy.NetworkOnly).build()
val response = apolloClient.query(request)
becomes
Copy code
val response = apolloClient.query(HeroQuery())
        .fetchPolicy(FetchPolicy.NetworkOnly)
        .execute()
n
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
He hates the sealed classes because they come out in a very 'un-swift' way
I see... In that case, you can use
Copy code
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
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
The codegen adds very little
_
. IIRC, this only happens for kotlin keywords like
for
,
fun
,
object
, etc..
n
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
Let us know what you find!
n
One final thing, as I go through this migration, what happened to the
queryCacheAndNetwork
function?
m
It's
executeCacheAndNetwork
now
n
Okay. Cool, thanks. Nice easy one.
m
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
It makes more sense as part of the execution flow, I just didn't find it because it used to be on apolloClient.
m
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
The fluent APIs look nicer. πŸ™‚
πŸ‘ 1
b
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
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
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! πŸ™‚