Closed mariusc23 closed 2 years ago
Finally had some time to do some digging into this and it seems like an issue with webpack and the fact that apollo-server doesn't publish ESM versions yet, but the graphql module does: https://github.com/apollographql/apollo-server/issues/4983 and https://github.com/apollographql/apollo-server/issues/5627
It seems like if gatsby wants to support apollo-server in functions there needs to be a way to customize the functions webpack config. I verified if I manually define extensions: ['ts', 'mjs', 'js', '...']
in the functions webpack config that it works. Is there a plan to support customizing the webpack config?
The comments https://github.com/apollographql/apollo-server/issues/4983#issuecomment-848428059 & https://github.com/apollographql/apollo-server/issues/5627#issuecomment-901656537 seem to suggest though that this would (also) be fixed with adding an alias. Gatsby doesn't support ESM right now so you can't use pure ESM packages out of the box just yet.
Yeah, alias should work too. Just need a way to configure the functions webpack config. The onCreateWebpackConfig
hook seems to be only for non-functions webpack.
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 💪💜
This is still an issue since there's no way to configure the functions webpack config AFAIK. Could file a ticket for that or rename this one if preferred?
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 💪💜
Hey again!
It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY
. Please feel free to comment on this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks again for being part of the Gatsby community! 💪💜
Preliminary Checks
Description
I wanted to set up a small graphql endpoint for the frontend to use (for forms), but I couldn't get apollo-server-micro to work. This is the error I got:
This happens when initializing the
ApolloServer
instance. If I run the file using node.js directly it does not throw an error on the same line, so I think Gatsby may be doing some loader magic that breaks things that need thegraphql
module, such as apollo server. I think this magic should be dispelled for Gatsby Functions.I have verified that indeed there is only one
graphql
module in my node_modules usingyarn why graphql
and manually checking.Reproduction Link
https://codesandbox.io/s/quirky-thompson-llnhk?file=/src/api/graphql.js
Steps to Reproduce
src/api/graphql.js
with a basic graphql server (see example below)/api/graphql
in browserExpected Result
The graphql endpoint would show
Actual Result
Error when executing function "/.../src/api/graphql.ts":
Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm. Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed. https://yarnpkg.com/en/docs/selective-version-resolutions Duplicate "graphql" modules cannot be used at the same time since different versions may have different capabilities and behavior. The data from one version used in the function from another could produce confusing and spurious results.
Environment
Config Flags
No response