-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Micro server not handling Network errors #1581
Micro server not handling Network errors #1581
Comments
When I use a vanilla apollo-server, my client recieves query errors (as documented) in the following manner: [GraphQL error]: Message: Schema is not configured for mutations. When using Micro server, instead of the two errors, a string is returned and is not understood by Apollo Client: To reproduce this - use the micro example and send an incorrect request. |
Had the same problem. For me this was happening when an error was throw in the Something like: context: () => {
throw new AuthenticationError('\'jwtToken\' must be a string.')
} Going through the source code I suspect the problem is in the top level micro error handling and supsquent response. } catch (error) {
if ('HttpQueryError' === error.name && error.headers) {
setHeaders(res, error.headers);
}
if (!error.statusCode) {
error.statusCode = 500;
}
throw error;
} Instead of throwing an error, we should return the result of the message. The message contains the correct json to be return as the response body. } catch (error) {
if ('HttpQueryError' === error.name && error.headers) {
setHeaders(res, error.headers);
}
if (!error.statusCode) {
error.statusCode = 500;
}
send(res, error.statusCode, error.message);
} |
**Updated below to issue with micro server *
When a mutation error occurs a JSON reponse with an error object is returned - the client can parse and handle this.
{data: {requestToken: null},errors: [{message: "Unknown User"}]
However, when a schema error or request error occurs, I get a string response which cannot be parsed client side.
HttpQueryError: {"errors":[{"message":"Variable.....}
This is using apollo-server-micro how should I catch these errors and provide a graceful message back to the client which could aide in debugging?
The text was updated successfully, but these errors were encountered: