mst-gql icon indicating copy to clipboard operation
mst-gql copied to clipboard

Add documentation around updating HttpClient

Open nicolasburtey opened this issue 5 years ago • 2 comments

I'm starting my app with the following RootStore:

export const wrapperCreateHttpClient = () => {
  return createHttpClient(GRAPHQL_URI, {
  headers: {
    authorization: Token.bearerString,
  },
})
}

RootStore.create(defaultStoreInstance, {
  gqlHttpClient: wrapperCreateHttpClient()
})

later down, if the user started unauthenticated (no bearer token stored), but receive his authentication, I'm updating the environment of the root storage:

const env = getEnv(store)
env["gqlHttpClient"] = wrapperCreateHttpClient()

yet, useQuery still uses the former gqlHttpClient that doesn't include the bearer token.

Any idea on how to resolve this?

nicolasburtey avatar Jun 07 '20 00:06 nicolasburtey

@nicolasburtey can you check https://github.com/mobxjs/mst-gql/issues/82 and see if it solves your issue? We might need to add docs around this.

chrisdrackett avatar Jun 08 '20 17:06 chrisdrackett

It did! can be closed on my side but some documentation around it would be nice indeed.

nicolasburtey avatar Jun 08 '20 18:06 nicolasburtey