question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Newest ReactJS amplify version broke our GraphQL endpoint connection

See original GitHub issue

Describe 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:

  1. Create an AppSync GraphQL endpoint API in the AppSync console that is authorized by AWS_IAM
  2. Connect it to a “create-react-app” application using Auth module to log into a Cognito User Pool
  3. 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
        }
    });
}
  1. 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);
});
  1. 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

aws-amplify-git-diff.log

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LeoTheMightycommented, Jan 24, 2019

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

0reactions
github-actions[bot]commented, Jun 12, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serverless GraphQL React App using AWS Amplify — Part Two
This command checks your local backend against what's running in the cloud, if there's an update or change or new feature, it provisions...
Read more >
Complete guide to full-stack CI/CD workflows with AWS Amplify
Today AWS Amplify launched new enhancements to it's CI/CD workflow for ... Create an app backend with a database and GraphQL API endpoint....
Read more >
Using nullability in GraphQL
So we can declare some fields to be non-null in our GraphQL schema, but that doesn't guarantee we won't have some code in...
Read more >
AWS Amplify Connect does not return data - Stack Overflow
I have configured Amplify with the GraphQL endpoint and region and verified that the connection works with this snippet:
Read more >
amplify-js
x.x you may need to rebuild your Datastore models with the latest version of Amplify ... React Native yarn add aws-amplify amazon-cognito-identity-js ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found