https://kotlinlang.org logo
Title
j

james

05/27/2021, 6:45 AM
Hi, I need to add a JWT header to my GraphQL subscription - does anyone know how to do this with apollo-android? (and somehow support refreshing jwts as well)
m

mbonnin

05/27/2021, 6:59 AM
You can use
ApolloClient.subscriptionConnectionParams()
to send additional information in the
init
message
Or if you need more control over it, you'll most likely have to implement your own
OperationMessageSerializer
j

james

05/28/2021, 2:05 AM
Thanks for getting back to me
My subscription fails with
java.io.EOFException
and no other details in
@Override
    public void onNetworkError(@NotNull Throwable t) {
      Callback<T> callback = this.originalCallback;
      if (callback != null) {
        callback.onFailure(new ApolloNetworkException("Subscription failed", t));
      }
      terminate();
    }
After a couple of minutes. Any idea what could cause this?
m

mbonnin

05/28/2021, 8:15 AM
Right, I've seen this as well. Not 100% sure what's the root cause. Most probably your backend requires a ping of some sort.
r

rocketraman

06/01/2021, 8:56 PM
The
ApolloRequestInterceptor
does not work with subscriptions @mbonnin?
r

rocketraman

06/01/2021, 9:14 PM
That sounds like a better approach then... use a standard interceptor like the built-in bearer token interceptor or a custom variation, and it should work for both regular calls and subscriptions.
👍 1
j

james

06/01/2021, 10:38 PM
Yeah the EOF was indeed a backend required ping. I was having issues using the Apollo interceptor for JWT behavior, but will take another look. Thanks both.
👍 1