Comments (7)
@Cyberlane can you paste a snippet of code showing me how you are hooking up formatError
to graphql-server-express
?
from apollo-errors.
@thebigredgeek sure, no problem. The code still needs a little refactoring to be clearer, right now I am just trying to make things work.
graphQLServer.use('/graphql',
bodyParser.json(),
(req, res, next) => fetchWithCookies(req, next, baseUrl, context),
graphqlExpress({
formatError,
schema,
context,
rootValue: {},
}));
bodyParser
=> require('body-parser')
fetchWithCookies
=> my own wrapper around node-fetch
to inject cookies - this basically sticks the new function on the graphql context and then calls next.
Everything else should make sense, but please ask if anything is unclear please shout!
from apollo-errors.
@Cyberlane Interesting. I'll definitely look into this later on this week. It might be a regression with newer versions of graphql-server
.
from apollo-errors.
@Cyberlane can you write a wrapper function and console.log
the raw error like this:
{
formatError: e => {
console.trace(e);
return formatError(e)
}
}
and paste the output here
from apollo-errors.
I was unable to reproduce on graphql-server-express
0.6.0. I am releasing apollo-errors
1.4.0 in just a couple minutes though, so why don't you try that out and see if it works?
from apollo-errors.
@thebigredgeek sorry for the late reply... time zones!
Before doing the update I had
Trace: { Error: ApolloError: FetchError/::/2017-03-15T08:05:55.133Z/::/null/::/{"errorGroup":"UNAUTHORIZED","errorCode":"AUT_00011","errorMessage":"Invalid session cookie"}
I have now upgraded to 1.4.0
as you suggested, and now my response looks like:
{
"data": null,
"errors": [
{
"message": "UnAuthorised: blark",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"installation"
]
}
]
}
and the trace looks like
Trace: { Error: UnAuthorised: blark
at C:\path\some-file.js:6:31
at tryCatch (C:\path\node_modules\es6-promise\dist\lib\es6-promise\-internal.js:195:12)
at invokeCallback (C:\path\node_modules\es6-promise\dist\lib\es6-promise\-internal.js:210:13)
at publish (C:\path\node_modules\es6-promise\dist\lib\es6-promise\-internal.js:178:7)
at publishRejection (C:\path\node_modules\es6-promise\dist\lib\es6-promise\-internal.js:120:3)
at flush (C:\path\node_modules\es6-promise\dist\lib\es6-promise\asap.js:98:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
message: 'UnAuthorised: blark',
locations: [ { line: 2, column: 3 } ],
path: [ 'installation' ] }
at Object.formatError (C:\path\graphql-server.js:21:17)
at C:\path\node_modules\graphql-server-core\src\runQuery.ts:75:30
at Array.map (native)
at format (C:\path\node_modules\graphql-server-core\src\runQuery.ts:72:23)
at C:\path\node_modules\graphql-server-core\src\runQuery.ts:140:38
at tryCatch (C:\path\node_modules\es6-promise\dist\lib\es6-promise\-internal.js:195:12)
at invokeCallback (C:\path\node_modules\es6-promise\dist\lib\es6-promise\-internal.js:210:13)
at publish (C:\path\node_modules\es6-promise\dist\lib\es6-promise\-internal.js:178:7)
at flush (C:\path\node_modules\es6-promise\dist\lib\es6-promise\asap.js:98:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
So it's a change, but it's still not working.
I am on the Apollo slack if it's easier to ask a few questions there to get to the bottom of this issue.
from apollo-errors.
Turns out to be a non-issue. Further down in my chain of code I was doing
Promise.all(...).catch((error => { log(error); throw new Error(error); });
when I should have had
Promise.all(...).catch((error => { log(error); throw error; });
Problem is solved.
from apollo-errors.
Related Issues (20)
- Work with schema stitching. HOT 4
- Data values as array of object instead of object HOT 2
- es6-error v4.1.0 breaks formatError HOT 4
- showPath option is not doing anything HOT 2
- Message not propagating in 1.7.1 HOT 18
- Feature Proposal: `internalData` Property on ApolloError Constructor HOT 2
- GraphQL response is always null HOT 2
- Spec compliant error HOT 19
- How to add formatError to subscriptions end-point HOT 3
- Returned error empty message HOT 5
- Reasoning behind the two-step error pattern? HOT 3
- Working with Apollo Server 2.0 HOT 5
- Where to add to GraphQL Yoga ? HOT 1
- Create V2.0 Branch HOT 2
- message as an object HOT 4
- losing stack trace, anyway to retain it ? HOT 5
- How do you compare a thrown error to an ApolloError type? HOT 2
- apollo-errors vs apollo-server built in ApolloError? HOT 2
- How to pass variables into the error message. HOT 2
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-errors.