Open edipox opened 8 years ago
I think we have to extend the DefaultNetworkLayer like:
export default class RelayNetworkLayer extends DefaultNetworkLayer {
sendQueries(requests): Promise {
return Promise.all(requests.map(request => (
this._sendQuery(request).then(
result => result.json()
).then(payload => {
if (payload.hasOwnProperty('errors')) {
const error: any = new Error(
'Server request for query `' + request.getDebugName() + '` ' +
'failed for the following reasons:\n\n' +
this.formatErrors(request, payload.errors)
);
error.source = payload;
this.onError(error);
request.reject(error);
} else if (!payload.hasOwnProperty('data')) {
const error = new Error(
'Server response was missing for query `' + request.getDebugName() +
'`.'
);
this.onError(error);
request.reject(error);
} else {
request.resolve({ response: payload.data });
}
}).catch(
error => {
this.onError(error);
request.reject(error);
}
)
)));
}
}
Then we could register onError and handle invalid tokens.
Currently when there is an auth error, for example an invalid access token. We have the following error:
Instead of this we should just redirect to login page with an explanatory message