vuex-orm / plugin-graphql

Vuex ORM persistence plugin to sync the store against a GraphQL API.
https://vuex-orm.github.io/plugin-graphql/
MIT License
227 stars 52 forks source link

Help needed: hook for http response headers (401) #71

Open adminfriso opened 5 years ago

adminfriso commented 5 years ago

I get a response of 401 if I am not authenticated in my graphql api.

Is there a way to centralised catch all errors from apollo and do something with it on 1 place.

phortx commented 5 years ago

Currently not. I'm open for suggestions and Pull Requests :)

adminfriso commented 5 years ago

@phortx thanks for your fast reply. Could you maybe help me with another question. Is there a way to update the options of VuexORM after you do this line VuexORM.use(VuexORMGraphQL, {options});

phortx commented 5 years ago

Nope. For dynamic behavior there would be a function. Like we're doing it with HTTP Headers.

I suggest something like this:

VuexORM.use(VuexORMGraphQL, {
  database: database,
  ...,
  onError(error) {
    // handle error here
  }
});