aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
88 stars 76 forks source link

Android GraphQL API Multi Auth: amplifyconfiguration.json does not update to include apiname #814

Open sang2412 opened 1 year ago

sang2412 commented 1 year ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

10.0.0

What operating system are you using?

Windows

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Amplify Categories

auth, api

Amplify Commands

Not applicable

Describe the bug

When using Amplify CLI to configure a graphql API with multiple authorization modes, amplifyconfiguration.json does not get updated completely. The required configuration under awsAPIPlugin is not done for the additional authorization mode.

The documentation clearly mentions -

The friendly_name illustrated here is created from Amplify CLI prompt.

Expected behavior

In amplifyconfiguration.json, the required configuration under awsAPIPlugin should automatically be done for the additional authorization mode, as mentioned in the documentation.

Reproduction steps

  1. Add a GraphQL API to an Android project using the Amplify CLI
  2. In authorization modes, choose Cognito User Pools as the primary one and IAM as the additional authorization modes.
  3. After completing the configuration, run Amplify Push.
  4. Check if amplifyconfiguration.json is updated correctly. Check if configuration for additional auth is done automatically under "awsAPIPlugin" as mentioned in the documentation.

GraphQL schema(s)

```graphql # Put schemas below this line ```

Log output

``` # Put your logs below this line ```

Additional information

No response

josefaidt commented 1 year ago

Hey @sang2412 :wave: thanks for raising this! I was able to reproduce this issue and noticed the following awsAPIPlugin block:

"awsAPIPlugin": {
  "814": {
      "endpointType": "GraphQL",
      "endpoint": "https://pe7uiod2xnhajlqvwpn7ernexa.appsync-api.us-east-1.amazonaws.com/graphql",
      "region": "us-east-1",
      "authorizationType": "AMAZON_COGNITO_USER_POOLS",
      "apiKey": "da2-6qocwp27ungjbefd76n3vbboha"
  }
}

Marking as a bug 🙂

sang2412 commented 1 year ago

Hi @josefaidt In the mean time, is it recommended to manually configure the awsAPIPlugin block? Hoping there won't be any security concerns with manual configuration.

josefaidt commented 1 year ago

Hey @sang2412 apologies for the delay here, but you should be able to add additional configs manually to the Amplify client in your app code as this file is prone to be overwritten