aws-amplify / amplify-studio

AWS Amplify Studio (Formerly Admin UI)
135 stars 31 forks source link

Cannot update conflict resolution settings #1040

Open jo2 opened 1 year ago

jo2 commented 1 year ago

How did you install the Amplify CLI?

npm

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

18.16.0

Amplify CLI Version

12.5.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

Describe the bug

I'm facing the issue, that Amplify Studio does not show my data model. Instead it displays an error message, that "New APIs created within Studio will now be configured with Conflict Resolution disabled by default. In order to use DataStore, this setting can be changed in the GraphQL API Settings page by selecting a conflict resolution option." When I activate Conflict Resolution, I can't hit save and deploy in Studio because that button is not displayed. As a solution I want to update this setting using the CLI.

To do so, I use amplify update api:

PS F:\git\kreinn\trackinn> amplify update api
? Select from one of the below mentioned services: GraphQL

General information
- Name: trackinn
- API endpoint: https://xxx.appsync-api.eu-central-1.amazonaws.com/graphql

Authorization modes
- Default: Amazon Cognito User Pool
- IAM

Conflict detection (required for DataStore)
- Conflict resolution strategy: Auto Merge

? Select a setting to edit Conflict resolution strategy  
? Select the default resolution strategy Auto Merge         
? Do you want to override default per model settings? No
⚠️ WARNING: owners may reassign ownership for the following model(s) and role(s): Payment: [owner], Invite: [owner], Booking: [owner], Staffing: [owner], Project: [owner], EmploymentRelationship: [owner], Employee: [owner], Cust
omer: [owner], Company: [owner]. If this is not intentional, you may want to apply field-level authorization rules to these fields. To read more: https://docs.amplify.aws/cli/graphql/authorization-rules/#per-user--owner-based-da
ta-access.
✅ GraphQL schema compiled successfully.

Edit your schema at F:\git\kreinn\trackinn\amplify\backend\api\trackinn\schema.graphql or place .graphql files in a directory at F:\git\kreinn\trackinn\amplify\backend\api\trackinn\schema
✅ Successfully updated resource

In my transform.conf.json I can see that this is set. When I then run amplify push the setting in Amplify Studio is still disabled.

Expected behavior

amplify update api in combination with amplify push should push the implemented changes to the cloud.

Reproduction steps

sadly, I can't reproduce this issue because in an other project everything works fine.

Project Identifier

7a15e020679dc93ffd0710267d909f36

Log output

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

Additional information

No response

Before submitting, please confirm:

ykethan commented 1 year ago

Hey @jo2, thank you for reaching. tried reproducing the issue but did not observe this behavior.

Created a schema and pushed which disabled the save and deploy button, then used Amplify CLI to enable conflict resolution and push. In the Studio application i refreshed the page and observed the Conflict resolution & offline capabilities enabled. Could you let know if there are any additional information that could assist in reproducing the issue. For example, API configuration.

transferring the issue to studio repository.

jo2 commented 1 year ago

Sadly, as I said, with another project I couldn't reproduce it myself. What kind of configuration information would help you, the cli-inputs.json or the backend-config.json for example?

ykethan commented 1 year ago

Hey @jo2, from the provided project identifier verified the cli-inputs.json, the file contains

"conflictResolution": {
      "defaultResolutionStrategy": {
        "type": "AUTOMERGE"
      }
    }

which indicates the conflict resolution is enabled. could provide us the following information.

  1. Check the S3 bucket managed by Amplify( for example: amplify-<project-name>-<envname>-93358-deployment) at path studio-backend/api/<project-name> for a transform.conf.json file containing the ResolverConfig block with the following
"ResolverConfig": {
        "project": {
            "ConflictHandler": "AUTOMERGE",
            "ConflictDetection": "VERSION"
        }
    }
  1. if the block is present, could you try opening the application in a inCognito window to confirm this.
  2. If the option does not still appear as enabled could you try pushing the API with a new empty line or a field and re-confirm the conflict resolution, do refresh the page once the amplify push finishes.
jo2 commented 1 year ago

Here is the content of the transform.conf.json of my environment:

{
    "Version": 5,
    "ElasticsearchWarning": true,
    "ResolverConfig": {
        "project": {
            "ConflictHandler": "AUTOMERGE",
            "ConflictDetection": "VERSION"
        }
    }
}

I ran the steps you've listed in your comment, I'm still facing the same issue.

ykethan commented 1 year ago

@jo2 interesting, this does provide the information that conflict resolution/Datastore has been enabled for the application. Do you observe any errors in the browser debug window? this can be done by opening the GraphQL API settings page and the browser debug window then refresh the studio window while keeping the debug window open.

jo2 commented 1 year ago

This is everything I got after refreshing the GraphQL API settings page: image

ykethan commented 1 year ago

Hey @jo2, the info messages should not effect the conflict resolution. Could you provide us the screenshot of the Data modelling API settings page and the data modelling page? Are there any errors in the debug console on data modelling page?

ykethan commented 1 year ago

additionally, could you ensure if the correct environment has been selected in studio. The a drop down list of env names should be present at the middle of the page.

jo2 commented 1 year ago

This is the content of the Data modeling page: image

Allthough I have a data model it is not displayed here. Normally, the Data modeling UI is not shown because I'm using the @index directive in my GraphQL backend and I'm using an @auth groupsField. I'm expecting to see the GraphQL schema view, though, which happens in other projects in that case.

ykethan commented 1 year ago

Hey @jo2, could you try pulling the stg env into a new folder locally outside your existing project root and verify the backend/api/schema.graphql file. Does the file have the expected schema. Additionally, would you be open for a quick call? I am available on discord at Eastern timezone. my handle is ykethan

jo2 commented 1 year ago

After running amplify pull --appId xxx --envName stg in an empty folder I receive the correct backend configuration. Both the schema.graphql and the transform.conf.json are as expected.

I'll contact you via discord for a meeting time.

ykethan commented 1 year ago

Hey @jo2, wanted to provide an update on this issue. I was successfully able to reproduce the issue. It appears the groupsField may be causing the Data modelling page to appear blank. From the network I was able to confirm that the schema is currently being pulled correctly and the Content such as Data manager does render the tables as well.

marking this as bug for further investigation.

jo2 commented 1 year ago

Thanks! I'm looking forward to having this fixed.

Originally I stumbled over this because running amplify mock api no schema was available. This is what I'm seeing running amplify mock api in amplify cli 12.0.0. I'm not using the current version because of this issue. image

I thought on checking up with the Amplify Studio Data modeling page, where I found that there was no schema either. Might this amplify mock issue being related to what I'm seeing in Amplify Studio?

ykethan commented 1 year ago

@jo2 interesting, thank you for the information. The team will need to dive in further to see if the issue is due to the resolvers. Tested the Data manager but did not experience an sync issue on the model.

note:, diving into the browser network logs it does appear the schema in Data modelling is currently retrieved but no errors were logged.

jo2 commented 1 year ago

Thanks! Let me know if there is some additional information from my part you may need.