Newest ReactJS amplify version broke our GraphQL endpoint connection
See original GitHub issueDescribe the bug After some new release of Amplify, our GraphQL and Lambda API endpoints no longer communicates correctly (but only sometimes?) and rather give us a 403 (forbidden) error with GraphQL and Lambda gives us a “Missing credentials in config […] Could not load credentials from CognitoIdentityCredentials.” However, the Auth module still allows logging in and is printing out the credentials correctly.
To Reproduce Steps to reproduce the behavior:
- Create an AppSync GraphQL endpoint API in the AppSync console that is authorized by AWS_IAM
- Connect it to a “create-react-app” application using Auth module to log into a Cognito User Pool
- Configure Amplify using something like this
import Amplify from "aws-amplify";
function setupAWS() {
Amplify.configure({
'aws_appsync_graphqlEndpoint': 'OUR_GRAPHQL_ENDPOINT_URL',
'aws_appsync_region': 'OUR_APPSYNC_REGION',
'aws_appsync_authenticationType': 'AWS_IAM',
});
Amplify.configure({
Auth: {
// REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
identityPoolId: 'OUR_IDENTITY_POOL_ID',
// REQUIRED - Amazon Cognito Region
region: 'OUR_COGNITO_REGION',
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'OUR_USER_POOL_ID',
// OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
userPoolWebClientId: 'OUR_WEB_CLIENT_ID',
},
Storage: {
bucket: 'OUR_BUCKET_NAME', //REQUIRED - Amazon S3 bucket
}
});
}
- Try to perform a query in the AppSync GraphQL Endpoint with something like this
import { API, graphqlOperation } from "aws-amplify-react";
API.graphql(graphqlOperation(queryString, queryVariables)).then((data) => {
console.log(JSON.stringify(data));
}).catch((error) => {
console.error(error);
});
- On the newer versions, this should give you a 403 error…
Expected behavior It should give us the query results (as it has been doing consistently in the past).
Desktop (please complete the following information):
- OS: Windows
- Browser Chrome
- Version…
It’s hard to tell which version is the issue, but by doing git diff on our yarn.lock file, we can see differences between the working version and the not working file. I saved the output from that and attached it to this issue. It’s huge, but searching for “aws” and/or “amazon” I found these key differences: WORKING VS. NOT-WORKING “@aws-amplify/analytics@”: ^1.2.8 VS. ^1.2.10 “@aws-amplify/cache”: ^1.0.20 VS. ^1.0.22 “@aws-amplify/core”: ^1.0.20 VS. ^1.0.22 “@aws-amplify/api”: ^1.0.24 VS. ^1.0.26 “@aws-amplify/auth”: ^1.2.13 VS. ^1.2.15 “amazon-cognito-identity-js”: ^3.0.6 VS. ^3.0.7 “@aws-amplify/interactions”: ^1.0.23 VS. ^1.0.25
“aws-amplify-react”: 2.2.4 VS. 2.3.0 “aws-amplify”: 1.1.17 VS. 1.1.19
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Just as an update, when we got this issue, the way we solved it was to literally get an old yarn.lock file from an earlier commit and run yarn install again. This leads us to believe that this is a purely Amplify-based bug. If it helps, the API module is the problematic one (with the GraphQL query), while the Auth module is still functioning as expected. Also, we use the aws-sdk to use Lambda, and that is also broken in this update. Both of these problems are fixed with this quick fix.
Thank you so much in advance, ~ Leo
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.