Coder Social home page Coder Social logo

Comments (4)

thebigredgeek avatar thebigredgeek commented on June 9, 2024

This should work with apollo-server out of the box. It was designed to work with it

from apollo-errors.

druidsgarden avatar druidsgarden commented on June 9, 2024

Not with apollo-server-lambda it doesn't seem to. I don't know whether it's down to the version of NodeJS we are restricted to (6.10) or my lack of knowledge of NodeJS as I'm fairly new to it.

I did get it all working eventually but I had to make the following changes:

I had to change the imports to use const and define each module discretely

The Error definitions all needed to be in seperate JS files:

'use strict';

const createError = require("apollo-errors").createError;

const UnknownError = createError('UnknownError',{
    message: 'An unknown error has occured'
});

module.exports = UnknownError;

In the apollo-handler

const formatError = require('apollo-errors').formatError;

const graphQLOptions = {
            schema: jsSchema,
            context: {
                "resolvers": Resolvers   
            },
            formatError: formatError,
            debug: true
        };                                                      

        //console.log(jsSchema);
        server.graphqlLambda(graphQLOptions)(event, context, callbackFilter);

I could then just throw the Error as needed.

It's a great library btw.

from apollo-errors.

thebigredgeek avatar thebigredgeek commented on June 9, 2024

Can you confirm whether or not this is still an issue with Lambda?

from apollo-errors.

n1ru4l avatar n1ru4l commented on June 9, 2024

I am using this package with apollo-server-lambda, it works fine and it is totally awesome! Thank you, I think we can close this issue ☺️

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.