-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Apollo Client is not compatible with Next.js _middleware due to eval/new Function calls #9128
Comments
+1 We really need some kind of solution for this we are stuck with Next 12.0.2 now. I'm using Apollo 3.5.5 Only current fix I'm aware of is to manually build the gql query in a fetch api query, which is not really ideal. |
@ncphillips What @VincentGillot Same question to you. To both of you: can you tell if the error is happening because the |
@benjamn it is Although
|
If I force install the latest version of
|
You might be on to something. I do not see any references to |
0.9.3 for me. , As for the second question I'm really not sure. Thing is the Next warning is now an error in the new version which is why it doesn't build. So no incompatible code might actually be run, specially since we are doing it locally, not on Edge servers. |
I didn't notice this question
That is the problem. Their webpack config does static analysis Here is where the error is created in the code |
Is everyone here still using Apollo Client v2 ( As for the static analysis, I'm almost relieved to hear that's what it is, because I'm quite confident we can obfuscate the code in a way that will thwart any static analysis. If the problem was that |
Alright, here's my plan for the obfuscation: apollographql/invariant-packages#233 Can anyone provide a reproduction that's using |
@benjamn ours is |
I'm going to update my demo repo to use @apollo/client so I can confirm if this works |
This is using the latest version of https://github.com/ncphillips/reproduce-apollo-middleware-build-failure (Aside: thanks for your help!) |
Sorry for the preemptive close! |
@ncphillips Can you try |
Woo! That worked! Well, almost It worked in my reproduction repo but not in my actual repo. It looks like there's another packages that end up importing old versions of Packages
Build Errors
|
This is a bit hacky (just for diagnostic purposes), but can you make any progress by removing those other rm -rf ./node_modules/apollo-link/node_modules/ts-invariant/
rm -rf ./node_modules/apollo-utilities/node_modules/ts-invariant/ This should force those packages to use If |
Okay super interesting. I'll look at importing via BUT IT BUILDS I updated the Next.js Webpack config to always resolve
So I can confirm that that's the issue. I'm going to push forward with this hack approach for my own benefit but I would suggest the |
@ncphillips My error shows because of this request in middleware and I don't have a solution for this. |
I had the same problem by importing a function with the |
I've got the same error, Why hasn't apollo-client just updated the package to [email protected]? |
@maximus-lynn Apollo Client has updated the dependency on |
I believe this issue has been resolved a long time ago - as a result, I'm going to close this. If you are still noticing this problem, please update your dependencies. Apollo Client 2 is very outdated at this point and we cannot guarantee any compatibility with modern Frameworks. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Intended outcome:
When using Apollo with Next.js I want to be able to use it in their new _middleware API
Actual outcome:
The build fails:
How to reproduce the issue:
Here is a repository that reproduces the issue
https://github.com/ncphillips/reproduce-apollo-middleware-build-failure
Versions
The text was updated successfully, but these errors were encountered: