ApolloClient Multiplatform and HTTP status codes

I’m aware that ApolloGraphQL server always returns a 200, regardless of whether a query succeeded or not. But that assumes that the connection actually made it to the GraphQL server.

My problem is that I need to log and handle other status codes that get returned from our gateway, such as 400, 401, 500, etc.

I’ve searched the usual spots, including here, but haven’t really found an answer that applies, especially re: Multiplatform. Is this status code available via ApolloResponse or some other mechanism?

Hi :wave: !

You can access the HTTP statusCode with:

response.executionContext[HttpResponseInfo]!!.statusCode

See here for an integration test that uses HttpResponseInfo. Extension functions and docs will be added the coming weeks, feel free to open an issue on the repo so we can track progress.

Thanks for the info. I’ll open a tracking issue.

1 Like