# Apollo mergeSchemas errors return Unexpected error value:

**URL:** <https://answers.netlify.com/t/apollo-mergeschemas-errors-return-unexpected-error-value/5759>\
**Category:** Support\
**Tags:** lambda-functions\
**Created:** [December 3, 2019, 3:46am UTC](https://answers.netlify.com/t/apollo-mergeschemas-errors-return-unexpected-error-value/5759 "2019-12-03T03:46:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kim\_re](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@kim\_re](https://answers.netlify.com/u/kim_re)\
**Post date:** [December 3, 2019, 3:46am UTC](https://answers.netlify.com/t/apollo-mergeschemas-errors-return-unexpected-error-value/5759/1 "2019-12-03T03:46:58Z")

</div>

Hello,

I’m using netlify functions Apollog GraphQL and Apollo Gateway Template for schema stitching. I throw AuthenticationError from apollo-server-lambda if login failed. However I always get INTERNAL\_SERVER\_ERROR. What should I do to fix this?

Gateway Function  
 ![image](https://global.discourse-cdn.com/netlify/original/2X/1/1fb309c004cf814911597248e83b663b662187af.png)

Login function  
const login = async (\_, { email, password }, \_context) =\> {  
let match = null;  
try {  
match = await client.query(q.Get(q.Match(q.Index(“user\_by\_email”), email)));  
} catch (err) {  
console.error(err);  
throw new AuthenticationError(“Wrong email or password”);  
}  
const user = match.data;

const valid = await bcrypt.compare(password, user.password);  
if (!valid) {  
throw new AuthenticationError(“Wrong email or password”);  
}  
return {  
accessToken: createAccessToken(user),  
refreshToken: createRefreshToken(user)  
};  
};

Error from Gateway  
{  
“errors”: [  
{  
“message”: “Unexpected error value: { message: “Wrong email or password”, locations: [[Object]], path: [“login”], extensions: { code: “UNAUTHENTICATED”, exception: [Object] } }”,  
“locations”: [  
{  
“line”: 2,  
“column”: 3  
}  
],  
“path”: [  
“login”  
],  
“extensions”: {  
“code”: “INTERNAL\_SERVER\_ERROR”,  
“exception”: {  
“errors”: [  
{  
“message”: “Unexpected error value: { message: “Wrong email or password”, locations: [[Object]], path: [“login”], extensions: { code: “UNAUTHENTICATED”, exception: [Object] } }”,  
“locations”: ,  
“path”: [  
“login”  
]  
}  
],  
“stacktrace”: [  
“Error: Unexpected error value: { message: “Wrong email or password”, locations: [[Object]], path: [“login”], extensions: { code: “UNAUTHENTICATED”, exception: [Object] } }”,  
" at new CombinedError (/home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/stitching/errors.js:82:28)",  
" at Object.checkResultAndHandleErrors (/home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/stitching/errors.js:98:15)",  
" at CheckResultAndHandleErrors.transformResult (/home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/transforms/CheckResultAndHandleErrors.js:9:25)",  
" at /home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/transforms/transforms.js:25:54",  
" at Array.reduce ()",  
" at applyResultTransforms (/home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/transforms/transforms.js:24:23)",  
" at /home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/stitching/delegateToSchema.js:105:50",  
" at step (/home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/stitching/delegateToSchema.js:32:23)",  
" at Object.next (/home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/stitching/delegateToSchema.js:13:53)",  
" at fulfilled (/home/senpai/Projects/adso/functions/gateway/node\_modules/graphql-tools/dist/stitching/delegateToSchema.js:4:58)"  
]  
}  
}  
}  
],  
“data”: {  
“login”: null  
}  
}

---

<div class="post-metadata">

**Author:** ![Dennis](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/dennis/32/34_2.png) [@Dennis](https://answers.netlify.com/u/Dennis)\
**Post date:** [December 5, 2019, 5:31pm UTC](https://answers.netlify.com/t/apollo-mergeschemas-errors-return-unexpected-error-value/5759/2 "2019-12-05T17:31:07Z")

</div>

Hello @kim_re, I’m not sure what the issue is exactly, but since your error messages are the same in two places, it’s hard to know which async call caused the error. You could try making them different so you can have a better idea. Hope that helps.
