Apollo-ios: GraphQLError parsing issue in response?.parsedResponse

Created on 27 Oct 2020  路  3Comments  路  Source: apollographql/apollo-ios

Hello Apollo community,
I am currently updating our codebase to support RequestChainNetworkTransport interface.
In a previous structure I used HTTPNetworkTransportGraphQLErrorDelegate to catch GraphQLError to initiate access token update and retryHandler to retry faild request.

With the new RequestChain structure I am perfoming same action inside ResponseCodeInterceptor. Though, GraphQLError is not being parced anymore. I am accessing it by response?.parsedResponse?.errors

Here is the response raw data:
{"errors":[{"message":"Access denied","path":["getUserDetails"],"locations":[{"line":2,"column":1}],"extensions":{"code":"accessTokenExpired"}}],"data":null}

Would love to get some help or suggestions where is the right way to fetch GraphQLError this time.
Am I doing something wrong?
Thanks

Versions

Please fill in the versions you're currently using:

  • apollo-ios SDK version: 0.36.0
  • Swift version: 5.3

All 3 comments

I would probably do this check in an interceptor that runs after LegacyParsingInterceptor - that's where the actual parsing takes place, and after it's gone through that inteceptor, you should be able to access it using response?.parsedResponse?.errors.

The ResponseCodeInterceptor that's provided by default is mostly just checking to make sure the response code is something vaguely sane before attempting to parse the result

Thank you @designatednerd !
I have added a new interceptor AccessTokenValidationInterceptor right after LegacyParsingInterceptor.
Solved. 馃檶

@StanislavCekunov Mind if we close this out?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ashiemke picture ashiemke  路  5Comments

ivanhoe picture ivanhoe  路  5Comments

plm75 picture plm75  路  4Comments

hiteshborse12 picture hiteshborse12  路  4Comments

Robuske picture Robuske  路  3Comments