mobxjs / mst-gql

Bindings for mobx-state-tree and GraphQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

before / after request query hooks

cjjenkinson opened this issue · comments

I've been using mst-gql in a production project for a few months now

We do encounter issues where we need to be able to access more parts of the query request lifecycle. The specific use case is to handle more subtle authentication flows and issues.

At the moment it is relatively simple to set the auth token for the http client.

self.gqlHttpClient?.setHeaders({ Authorization: token });

The problem is when the token has expired or invalid the error will bubble up as a query error.

It would be nice to add a Promise based callback before and after a query is executed on the MSTGQLStore for not just these types of issues but more.

Before I dive into a proposal and spend time on it. Is there something I missed or haven't considered around control of the request lifecycle or would this be a welcomed addition?