Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseConfig should optionally accept an object, instead of reading from the filesystem #150

Closed
stephengfriend opened this issue Mar 27, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@stephengfriend
Copy link

stephengfriend commented Mar 27, 2020

I'm currently trying to deploy GraphQL Mesh on @zeit Now as a Next.js API route. No matter where I place the .meshrc.yaml, it can't be found.

[POST] /api/mesh

2020-03-27T05:53:20.824Z	b1b51018-01d9-45ad-886e-1b114097e663	ERROR	TypeError: Cannot read property 'require' of undefined    at parseConfig (/var/task/node_modules/@graphql-mesh/runtime/dist/parse-config.js:25:16)    at async module.exports.vbkO.__webpack_exports__.default (/var/task/.next/serverless/pages/api/mesh.js:283:84)    at async apiResolver (/var/task/node_modules/next/dist/next-server/server/api-utils.js:48:9)

I also tried to deploy it out as a standalone function on @zeit Now and even when I could confirm the file was present, it still couldn't find the config.

[POST] /api/mesh

.meshrc.json
mesh.js
mesh.js.map

2020-03-27T14:38:38.136Z	504307a5-1c46-4f80-816d-95ea581ec08f	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: Cannot read property 'require' of undefined","reason":{"errorType":"TypeError","errorMessage":"Cannot read property 'require' of undefined","stack":["TypeError: Cannot read property 'require' of undefined","    at parseConfig (/var/task/node_modules/@graphql-mesh/runtime/dist/parse-config.js:25:16)","    at _default (/var/task/api/mesh.js:22:61)","    at Server.<anonymous> (/var/task/___now_helpers.js:869:13)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'require' of undefined","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:323:22)","    at process.emit (/var/task/__sourcemap_support.js:2535:21)","    at processPromiseRejections (internal/process/promises.js:209:33)","    at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
Unknown application error occurred

It would be helpful for serverless scenarios to allow passing the config object into parseConfig directly. This would also enable the use of ENV_VARS for secrets, such as API Keys.

@damacisaac
Copy link

Ran into the same issues getting started. Had a hard time getting parseConfig to find my config file, and then realized I wouldn't be able to use it with different environment variables. Happy to help out in any way.

@stephengfriend
Copy link
Author

I confirmed the changes made by @ardatan were good and will be releasing a write-up of how I've deployed Mesh as a gateway on Zeit Now and consumed it as a hasura remote schema later today.

@ardatan
Copy link
Owner

ardatan commented Apr 2, 2020

Available in 0.0.17 🎉

@ardatan ardatan closed this as completed Apr 2, 2020
@praneybehl
Copy link

@stephengfriend Nice, did you end up doing the writeup somewhere? Would be great to checkout how you accomplished that. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants