Coder Social home page Coder Social logo

Comments (7)

thebigredgeek avatar thebigredgeek commented on May 31, 2024

@Cyberlane can you paste a snippet of code showing me how you are hooking up formatError to graphql-server-express?

from apollo-errors.

Cyberlane avatar Cyberlane commented on May 31, 2024

@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.

thebigredgeek avatar thebigredgeek commented on May 31, 2024

@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.

thebigredgeek avatar thebigredgeek commented on May 31, 2024

@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.

thebigredgeek avatar thebigredgeek commented on May 31, 2024

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.

Cyberlane avatar Cyberlane commented on May 31, 2024

@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.

Cyberlane avatar Cyberlane commented on May 31, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.