Closed jasonrdunne closed 7 months ago
Hi @jasonrdunne, closing this issue with the details from our discussion on the Discord server that unblocked you as far as this issue as it was caused by a misconfiguration and overlapping aws-amplify package versions. We can continue troubleshooting any other issues you run into in the Discord server.
Here is the correct configuration code for v6 of aws-amplify
.
// Next.js - app/layout.tsx
"use client";
import { Amplify } from "aws-amplify";
import type { ResourcesConfig } from "aws-amplify";
const config: ResourcesConfig = {
Auth: {
Cognito: {
userPoolId: process.env.NEXT_PUBLIC_USER_POOL_ID as string,
userPoolClientId: process.env.NEXT_PUBLIC_USER_POOL_CLIENT_ID as string,
},
},
API: {
GraphQL: {
endpoint: "https://my-endpoint.com/",
region: "us-east-1",
defaultAuthMode: "userPool",
},
},
};
Amplify.configure(config, { ssr: true });
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, GraphQL API
Amplify Version
v6
Amplify Categories
auth, api
Backend
None
Environment information
I use next 14 app router with react and typescript
Describe the bug
I've been trying to set up amplify to do graphql calls to appsync. Note I created appsync separately in CDK. When i try to do a graphql request, such as a mutation, I get this error:
This is how i configured:
You can see API is 'null' in the amplify object, yet auth worked:
Expected behavior
I would expect API to exist because I specified it.
Reproduction steps
By "configuring" in layout.tsx, and printing the amplify object
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response