genql icon indicating copy to clipboard operation
genql copied to clipboard

Handling Hasura authentication error with batched queries

Open kvnbra opened this issue 2 years ago • 0 comments

Hi!

I'm using a Genql client to access an Hasura instance with a JWT Authentication header and I struggle to handle the authentication error when queries are batched because the Genql fetcher throw a:

Error: response length did not match query length.

On page load I have two queries GetApp and GetUser, so the request body look like that:

{query: "query GetApp{app{name}}", variables: {}}
{query: "query GetUser{user{name,lastname}}", variables: {}}

And the response is:

{
    "errors": [
        {
            "message": "Could not verify JWT: JWSError JWSInvalidSignature",
            "extensions": {
                "path": "$",
                "code": "invalid-jwt"
            }
        }
    ]
}

So I get why the fetcher is throwing that, but do I have any way to access/handle this kind of response without disabling batching?

kvnbra avatar Oct 19 '23 11:10 kvnbra