-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Functions not compatible with apollo server #33047
Comments
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: apollographql/apollo-server#4983 and apollographql/apollo-server#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 |
The comments apollographql/apollo-server#4983 (comment) & apollographql/apollo-server#5627 (comment) 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 |
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. 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. 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. 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
The text was updated successfully, but these errors were encountered: