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

GraphQLError: adapter is not a function Next.js getInitialProps #4311

Closed
ryanmalesic opened this issue Oct 31, 2019 · 16 comments · Fixed by #4678
Closed

GraphQLError: adapter is not a function Next.js getInitialProps #4311

ryanmalesic opened this issue Oct 31, 2019 · 16 comments · Fixed by #4678
Assignees
Labels
GraphQL Related to GraphQL API issues SSR Issues related to Server Side Rendering

Comments

@ryanmalesic
Copy link

Describe the bug
GraphQLError: adapter is not a function
at APIClass. (/Users/ryanmalesic/Projects/tdee-online/node_modules/@aws-amplify/api/dist/aws-amplify-api.js:5565:24)
at step (/Users/ryanmalesic/Projects/tdee-online/node_modules/@aws-amplify/api/dist/aws-amplify-api.js:4733:19)
at Object.throw (/Users/ryanmalesic/Projects/tdee-online/node_modules/@aws-amplify/api/dist/aws-amplify-api.js:4663:14)
at rejected (/Users/ryanmalesic/Projects/tdee-online/node_modules/@aws-amplify/api/dist/aws-amplify-api.js:4625:32)
at runMicrotasks ()
at processTicksAndRejections (interna

To Reproduce
Steps to reproduce the behavior:

Query in getinitialProps of a nextjs app

Expected behavior
It should query, not throw

@ryanmalesic ryanmalesic added the to-be-reproduced Used in order for Amplify to reproduce said issue label Oct 31, 2019
@ryanmalesic
Copy link
Author

Doing more stack tracing, this seems to be an axios issue. I have put a discussion in there. I will close this if an axios fix can correct the issue

@jordanranz
Copy link
Contributor

Hey @ryanmalesic, is there an issue open to track the axios discussion?

@jordanranz jordanranz added GraphQL Related to GraphQL API issues and removed to-be-reproduced Used in order for Amplify to reproduce said issue labels Nov 1, 2019
@ryanmalesic
Copy link
Author

ryanmalesic commented Nov 1, 2019

Hey @ryanmalesic, is there an issue open to track the axios discussion?

@jordanranz
axios/axios#2507

@weizliu
Copy link

weizliu commented Nov 9, 2019

Any updates? I ran into this issue too

@weizliu
Copy link

weizliu commented Nov 11, 2019

Is the change in 1.2.4 already? I ran into the same issue while using 1.2.4 today.

@aliankarali
Copy link

Still having this issue with @aws-amplify/api@2.1.1 on server side. Axios issue is closed, I don't know if it is related to amplify or axios.

@simpleshadow
Copy link

simpleshadow commented Dec 7, 2019

Getting the same error with Next.js and aws-amplify@2.2.0.

From axios/axios#2507 (comment), this looks to be an @aws-amplify/api issue.

Not seeing a workaround. Spent the day getting a Next.js project up only to hit this issue. 🙃

CC @jordanranz

@simpleshadow
Copy link

I got rid of the error using what I needed from. #4305 (comment)

@aliankarali
Copy link

@simpleshadow, thanks for the tip, I got it working by locking down the versions with resolutions as well.

@lambda0xff
Copy link

Getting the same error with a Nuxt.js application after trying to upgrade aws-amplify to the latest (^2.2.1)

Please Amplify-JS team, show a little more love for SSR frameworks, they shouldn't be treated like afterthoughts.

@aliankarali
Copy link

Forgot to mention that I get this error with express.js. it's not related to a specific ssr framework.

@Amplifiyer Amplifiyer added the SSR Issues related to Server Side Rendering label Jan 7, 2020
@Amplifiyer
Copy link
Contributor

I think I know the root cause. NuxtJs/NextJs are consuming the amplify library using the main field and not the modules field. Currently main field points to a webpack umd build which obviously shims the process variable preventing axios to determine the right environment.

I'll look into changing the main field to point to a cjs modules entry point.

Anyone knows if there is a way for Nuxt/NextJs apps to read the modules field in library's package.json instead of main?

@Amplifiyer
Copy link
Contributor

@ryanmalesic @weizliu @aliankarali @lambda0xff @simpleshadow We have just merged in the fix. Can you please try with aws-amplify@unstable version and let us know if it's fixing the issue?

@Amplifiyer Amplifiyer added the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Jan 8, 2020
@lambda0xff
Copy link

Seems to fix the issue for me.
aws-amplify": "^2.2.1-unstable.21

@stale stale bot removed the pending-close-response-required A response is required for this issue to remain open, it will be closed within the next 7 days. label Jan 8, 2020
@rehanbabertkxel
Copy link

rehanbabertkxel commented Jan 8, 2020

Yes, it seems like it resolved the issue @Amplifiyer .

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
CongNguyen086 pushed a commit to CongNguyen086/amplify-js that referenced this issue Oct 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
GraphQL Related to GraphQL API issues SSR Issues related to Server Side Rendering
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants