I am trying to use the Apollo client in my functions, and the creation of a client variable is throwing an error, but it just gives messages like
Invariant Violation: Invariant Violation: 1 (see https://github.com/apollographql/invariant-packages)
at new t (/var/www/html/cartoonistdb-frontend/built-lambda/send_contact_email.js:16:80875)
at /var/www/html/cartoonistdb-frontend/built-lambda/send_contact_email.js:16:82225
at jt (/var/www/html/cartoonistdb-frontend/built-lambda/send_contact_email.js:16:82235)
at new t (/var/www/html/cartoonistdb-frontend/built-lambda/send_contact_email.js:16:85135)
at new t (/var/www/html/cartoonistdb-frontend/built-lambda/send_contact_email.js:16:86965)
at Object.exports.handler (/var/www/html/cartoonistdb-frontend/built-lambda/send_contact_email.js:16:87513)
at /var/www/html/cartoonistdb-frontend/node_modules/netlify-lambda/lib/serve.js:133:27
I checked with the Apollo docs and they say it’s shortening the error messaging because it’s running from a production environment (which it isn’t, I’m testing the function locally), so I’m not sure what I can do to get more verbose error messaging. Any help would be appreciated!
Hmm, I haven’t seen that error message before, and I do believe that it comes from some of your code even if not intended by you - rather than something from our system which would be more likely to say “module not found” or something similarly pointing to “how function was created” rather than “how function runs” - once it’s to running, generally, that’s in your code if it fails. It looks from the stack trace like you’re using netlify-lambda serve to test and seeing that - could you confirm?
Regardless, I’d suggest figuring out how to convince Apollo that your environment isn’t production to get the full error message Maybe it’s as easy as setting NODE_ENV to development? Not sure as I don’t use Apollo but that’d be where I’d start debugging from here.
It looks from the stack trace like you’re using netlify-lambda serve to test and seeing that - could you confirm? Any chance you can share your
Yes, I’m using netlify-lambda serve to test. My function is super simple at this point. The error is coming from trying to create a new ApolloClient object (since that’s virtually all that’s happening in the function at the moment).
import ApolloClient from “apollo-boost”;
import gql from “graphql-tag”;
Thanks, @futuregerald! I’m having trouble figuring out where to set the NODE_ENV environment variable. I’ve set it in the .env file for my overall project (which the function doesn’t seem to have access to), and I set it in my netlify.toml file and no luck there either. Is there another place I should be setting it?