Coder Social home page Coder Social logo

Comments (5)

AdelBachene avatar AdelBachene commented on June 9, 2024

I have the same problem eventhough adding the source error in the internalData and data

       data: {
            sourceMessage: (error.message) ? error.message : "",
            sourceStatusCode: (error.code) ? error.code : ""
        },
        internalData: {
            sourceError: error
        }

I could still see it in all catches but I lost when it arrives at format error Im able to see the message only

 import {isInstance as isApolloErrorInstance, formatError as formatApolloError} from 'apollo-errors';
    graphqlExpress((req) => 
                 ({
                    schema: schema,
                    context: {
                        req: req
                    },
                    formatError: formatApolloError,
                    debug: true,
                    tracing: true,
                    cacheControl: false
                })
        )

-------------------------------> I found out that my issue was because of the schema stitching where it will swallow the original error and my work around for this is:

import {isInstance as isApolloErrorInstance, formatError as formatApolloError} from 'apollo-errors';

                   formatError: (error) => {
                        let errors: any[] = [];
                        error.originalError.errors.forEach((currentError) => {
                            let currentOriginal = currentError.originalError;
                            if (isApolloErrorInstance(currentOriginal)) {
                                Logger.Instance().gatewayError(currentOriginal);
                            }
                            errors.push(formatApolloError(currentOriginal, false));
                        });
                        return (errors.length > 1) ? errors : errors[0];
                    }

from apollo-errors.

thebigredgeek avatar thebigredgeek commented on June 9, 2024

@appsolutegeek are you using schema stitching as well?

from apollo-errors.

iangregsondev avatar iangregsondev commented on June 9, 2024

no, I used another library to merge my schema...

from apollo-errors.

codegoblin avatar codegoblin commented on June 9, 2024

@thebigredgeek I am also curious how one should go about solving this problem. Let's say my model layer is calling a connector and that connector throws an error. What's the proposed way to bubble up that original error's stacktrace to the graphql response's errors array? If you use an ApolloError in the resolver to mask the original connector error, it would seem that the returned stacktrace is pointing to the resolver error rather than the original trouble spot in the connector.

from apollo-errors.

thebigredgeek avatar thebigredgeek commented on June 9, 2024

PRs welcome on this. Closing for now

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.