I'm upgrading one of my projects to apollo 3 -- am...
# apollo-kotlin
r
I'm upgrading one of my projects to apollo 3 -- am I right in assuming the equivalent of
ApolloResponse.operation.variables()
for logging/error reporting purposes would be
variables(CustomScalarAdapters.PassThrough)
?
m
If you have custom scalars in your variables, you must pass the adapters for them
If not just use
CustomScalarAdapters.Empty
(result will be the same but it's more correct)
Besides that yep, should be the equivalent
r
I do have custom scalars, but I'm not doing anything important here except logging, so I don't really care if the transformation is correct. I just need the data.
Doesn't apollo have a list of the custom adapters internally? Why do I need to pass them?
m
Then
PassThrough
would technically work but I wouldn't really recommend it
all operations are standalone, they don't have a reference to the
ApolloClient
🆗 1
Reason is you can use the generated models without
ApolloClient
completely and substitute your own HTTP client and what not
(using
apollo-api
instead of
apollo-runtime
)
r
Makes sense, thanks. I guess I can just re-use the same list I pass into the client at build time. I haven't migrated that code yet 🙂
m
Exactly, make a toplevel variable with your global
CustomScalarAdapters
and re-use that
r
Thanks!
m
Sure thing!
r
Related to my upgrade: is there a replacement for
connectTimeoutMillis
in the http network transport?
Lots of nice improvements in 3. My only gripe so far is the use of
Optional
which is likely (and does for me) cause a namespace collision requiring aliasing.
m
is there a replacement for
connectTimeoutMillis
in the http network transport?
If you're on the JVM you can use
Copy code
apolloClient = ApolloClient.Builder()
        .serverUrl(mockServer.url())
        .httpEngine(
            DefaultHttpEngine(connectTimeout = 10_000, readTimeout = 10_999)
        )
        .build()
r
No its multi-platform code
m
Then there's a single parameter KMP method:
Copy code
apolloClient = ApolloClient.Builder()
        .serverUrl(mockServer.url())
        .httpEngine(
            DefaultHttpEngine(10_000)
        )
        .build()
It's used for both connect and read timeout. The details are a bit hairy
Like not all engine have the same semantics for all the different timeouts
👍 1
Lots of nice improvements in 3.
Thanks!
the use of
Optional
which is likely (and does for me) cause a namespace collision requiring aliasing
If you're willing to skip 3.0 and go directly to 4.0 alphas, there's an option to generate builders which might remove some of those optionals
r
Ah nice