-
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
Apollo Server returns INTERNAL_SERVER_ERROR as code after throwing AuthenticationError #1100
Comments
@harisvsulaiman Thanks for opening the issue! Where are you throwing the If you have a chance to create a test, in the style of this example, I would love to help solve the issue! |
I'm throwing the error in the resolver
On Wed 30 May, 2018, 10:13 AM Evans Hauser, ***@***.***> wrote:
@harisvsulaiman <https://github.com/harisvsulaiman> Thanks for opening
the issue!
Where are you throwing the AuthenticationError? Does it happen in
resolvers or are you throwing it in the context function?
If you have a chance to create a test, in the style of this example
<https://github.com/apollographql/apollo-server/pull/1063/files#diff-4793189b9a83e7b56e97bd024540b79fR332>,
I would love to help solve the issue!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1100 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ab-HrUYvIuWsm4btTPMNqlusGi337kT9ks5t3iNUgaJpZM4UPMY5>
.
--
Harisvsulaiman.
|
Ah okay, are you running with NODE_ENV set to production? I've got a hunch that the error is getting masked in that case. The other option could be that when the error is propagated up because the non-nullability it changes how the error is handled. Can you post the section of your schema and what your resolvers look like? |
@harisvsulaiman If you have a stacktrace for the error, that would be extremely helpful as well! |
Solved with #1113 |
Hey @evans. I'm still getting the same generic error. Should I open a new issue? Query: {
contacts: (root, args, { models }) => {
throw new AuthenticationError('must authenticate');
},
}, results in: {
"data": {
"contacts": null
},
"errors": [
{
"message": "must authenticate",
"locations": [],
"path": [
"contacts"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"errors": [
{
"message": "must authenticate",
"locations": [],
"path": [
"contacts"
]
}
],
"stacktrace": [
"Error: must authenticate",
" at new CombinedError (/app/node_modules/graphql-tools/src/stitching/errors.ts:85:5)",
" at Object.checkResultAndHandleErrors (/app/node_modules/graphql-tools/src/stitching/errors.ts:107:11)",
" at CheckResultAndHandleErrors.transformResult (/app/node_modules/graphql-tools/src/transforms/CheckResultAndHandleErrors.ts:15:12)",
" at /app/node_modules/graphql-tools/src/transforms/transforms.ts:37:45",
" at Array.reduce (<anonymous>)",
" at applyResultTransforms (/app/node_modules/graphql-tools/src/transforms/transforms.ts:35:21)",
" at /app/node_modules/graphql-tools/src/stitching/delegateToSchema.ts:81:12",
" at step (/app/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:32:23)",
" at Object.next (/app/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:13:53)",
" at fulfilled (/app/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:4:58)",
" at <anonymous>",
" at process._tickCallback (internal/process/next_tick.js:182:7)"
]
}
}
}
]
} I'm using:
EDIT: nevermind, I was using the old docs as reference. Now I see what was my error |
@evans I apologize for the delay! |
It seems that there are some issues between schema stitching and apollo errors: |
Sorry for cross-linking but found this github issue after I posted my comment. I think we are seeing this issue as well (ardatan/graphql-tools#480 (comment)) when we throw a ApolloError or AuthenticationError from our resolver. |
@todkap I'm also having the same problem using |
Our issue was on the graphql-tools version, rolled back from 4.0.1 to 3.1.1
Also need to apply formatError word-around that suggested by other posts in order to get this to work. |
I am also experiencing this error - I have these packages installed and I am using
|
Currently having the same issue adding an authentication middleware to my API. This is my middleware right now (unfinished), it get's called whenever a user requests information from a secured API and I always receive this error:
|
UPDATE
|
Apollo Server @2.0beta
returns INTERNAL_SERVER_ERROR as code after throwing AuthenticationError.As per the docs it should have thrown UNAuthenticated as code in extentions
code
throw AuthenticationError("Please Signin");
package.json
error
The text was updated successfully, but these errors were encountered: