Is there a way to view the raw http response or error for a GraphQL call generated by Apollo Client in React Native?
Asked Answered
X

0

7

I'm using Apollo Client v3.5.10 in React Native in a project managed by Expo v44.0.6. Occasionally, a GraphQL query returns an error that says Unexpected token < in JSON at position 0. I understand this means the server is returning HTML instead of well-formatted JSON.

Does anyone know how to see this raw response via code? I can see it in the Network inspector within the iOS Simulator (often a 404), but this is very inconvenient and doesn't help me in production.

I've tried creating an error link via onError (from @apollo/client/link/error). It works, but is only able to show me that same 'Unexpected token...' message. I haven't figured out if there's a way to see the actual raw HTML response or get the status via code.

Any help would be greatly appreciated.

Xenon answered 8/6, 2022 at 18:50 Comment(1)
Did you find a solution for this?Sulfonate

© 2022 - 2024 — McMap. All rights reserved.