Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerated code has relationship ID in queries #1065

Open
4 tasks done
fistofzen opened this issue Nov 11, 2023 · 16 comments
Open
4 tasks done

Autogenerated code has relationship ID in queries #1065

fistofzen opened this issue Nov 11, 2023 · 16 comments
Labels
pending-response An issue is pending response from the issue requestor studio-ui An issue that needs to be tracked by Studio Console team ui-forms issues related to UI builder forms

Comments

@fistofzen
Copy link

Before opening, please confirm:

App Id

d22h1kgc6xq1y7

Region

eu-central-1

Environment name

rescue

Figma File Version (if applicable)

No response

Amplify CLI Version

No response

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

No response

What operating system are you using?

No response

Browser type?

No response

Describe the bug

Hello,
when I pull the UI Library code, it also generates the relationship ID under queries.
for example abcTypesByAbcID is not in queries file.

import {
abcTypesByAbcID,
getAbc,
listTypes,
listUsers,

} from "../graphql/queries";

Regards.

Expected behavior

Not create abcTypesByAbcID,

Reproduction steps

pull UI-Library on react.

Project Identifier

No response

Additional information

No response

@fistofzen fistofzen added the pending-triage An issue that is pending triage label Nov 11, 2023
@ykethan
Copy link
Member

ykethan commented Nov 15, 2023

Hey @fistofzen, thank you for reaching out. To further dive deeper into the issue, could you provide some additional information.
Are you observing the abcTypesByAbcID being generated in the UI components such as forms?
is Relationship fields enabled on the UI Library settings? if yes and the use case does not require relationship fields, could you try disabling this and run amplify pull

@ykethan ykethan added studio-ui An issue that needs to be tracked by Studio Console team ui-forms issues related to UI builder forms labels Nov 15, 2023
@fistofzen
Copy link
Author

Hello Yes, generated ui has abcTypesByAbcID .
It was enabled. I disabled it but the same happened after amplify pull. you can check generated code for WorkoutUpdateForm.jsx.

import {
challengeWorkoutsByWorkoutID,
coachWorkoutsByWorkoutID,
.
.
.
.
programWorkoutsByWorkoutID,
} from "../graphql/queries";

@fistofzen
Copy link
Author

fistofzen commented Nov 16, 2023

The problem is with relationships flag. when I enable it, it generates the wrong form code as I mentioned above. Is there any workaroubnd for it?

@ykethan
Copy link
Member

ykethan commented Nov 16, 2023

Hey @fistofzen, to better understand i will need to reproduce the behavior. If the these are auto-generated forms due to data models(GraphQL API). Can you run amplify diagnose --send-report and provide us the Project Identifier output from your terminal.

@ykethan ykethan added the pending-response An issue is pending response from the issue requestor label Nov 16, 2023
@fistofzen
Copy link
Author

Project Identifier: bcba48597721297b52afcb62d9794b69

@github-actions github-actions bot removed the pending-response An issue is pending response from the issue requestor label Nov 18, 2023
@fistofzen
Copy link
Author

And also when I debug the code on amplify studio ->Content page. it has the same problem

@ykethan
Copy link
Member

ykethan commented Nov 20, 2023

Hey @fistofzen, thank you for the information. Tried reproducing the issue but i did not observe the error message or import in the workout update form.
the form generated locally had

import { getWorkout } from "../graphql/queries";

was the data model updated?

What is the local Amplify CLI version(amplify -v) and aws-amplify, @aws-amplify/ui-react in the package.json present?
i tested the forms using the latest version of cli 12.8.2 and "aws-amplify": "^6.0.3" ,"@aws-amplify/ui-react": "^6.0.2", Could you try upgrading the cli and packages, then run amplify pull to regenerate the components?

@ykethan ykethan added the pending-response An issue is pending response from the issue requestor label Nov 20, 2023
@fistofzen
Copy link
Author

fistofzen commented Nov 20, 2023

Hello, I am using relationships.

amplify version is 12.8.2, and versions are :
"@aws-amplify/ui-react": "^6.0.2",
"@aws-amplify/ui-react-storage": "^1.2.4",
"aws-amplify": "^6.0.3",

when you check WorkoutUpdateForm.jsx you will see the challengeWorkoutsByWorkoutId, coachWorkoutsByWorkoutId and others in the jsx file.

import {
challengeWorkoutsByWorkoutId,
coachWorkoutsByWorkoutId,
...
programWorkoutsByWorkoutId,
workoutMusleGroupsByWorkoutId,
workoutTrainingTypesByWorkoutId,
} from "../graphql/queries";

I observed the same issue in UI Library on Amplify Console also. when you check the F12 console as in screenshot
image

@github-actions github-actions bot removed the pending-response An issue is pending response from the issue requestor label Nov 20, 2023
@ykethan
Copy link
Member

ykethan commented Nov 21, 2023

Hey @fistofzen, thank you for the information. On enabling the relationship fields in the UI builder did notice some behaviours and errors but wasnt able to replicate the same error message about the ID field not being defined.
in my case it was TypeError: record.muscleGroups.toArray is not a function

@ykethan ykethan added bug An issue which has been identified as a bug and removed pending-triage An issue that is pending triage labels Nov 21, 2023
@fistofzen
Copy link
Author

Hello ykethan,
will be happy if you delete the screenshots. By the way how can I clear all forms and rebuild them again from ampliy console. maybe this is a cache issue.

@ykethan ykethan removed the bug An issue which has been identified as a bug label Nov 21, 2023
@ykethan
Copy link
Member

ykethan commented Nov 21, 2023

@fistofzen dived into the error message and noticed I was actually running into auth errors on modifying the default auth I was able to mitigate the errors.

Addditonally, locally, I had previously ran amplify update codegen with depth level 3 which may be the reason why i am not experiencing the errors.
Could you try modifying as following?

 amplify update codegen
? Choose the code generation language target javascript
? Enter the file name pattern of graphql queries, mutations and subscriptions src/graphql/**/*.js
? Enter maximum statement depth [increase from default if your schema is deeply nested] 3

then run amplify pull

@ykethan ykethan added the pending-response An issue is pending response from the issue requestor label Nov 21, 2023
@fistofzen
Copy link
Author

fistofzen commented Nov 27, 2023

Hello, didnt worked.
Still seeing the queries with ID ,

import {
challengeWorkoutsByWorkoutID,
'''
programWorkoutsByWorkoutID,
'''
} from "../graphql/queries";

Regards

@github-actions github-actions bot removed the pending-response An issue is pending response from the issue requestor label Nov 27, 2023
@ykethan
Copy link
Member

ykethan commented Nov 28, 2023

Hey @fistofzen, on further diving into the project noticed the cli.json seems to missing some flags, specifically enableAutoIndexQueryNames is missing which may be causing this behavior. Is this project built on a older version of Amplify CLI?

could you update the cli.json to as follows then run push to update the api. could you then check if the challengeWorkoutsByWorkoutID does appear in form queries.

{
    "features": {
        "graphqltransformer": {
            "addmissingownerfields": true,
            "improvepluralization": false,
            "validatetypenamereservedwords": true,
            "useexperimentalpipelinedtransformer": true,
            "enableiterativegsiupdates": true,
            "secondarykeyasgsi": true,
            "skipoverridemutationinputtypes": true,
            "transformerversion": 2,
            "suppressschemamigrationprompt": true,
            "securityenhancementnotification": false,
            "showfieldauthnotification": false,
            "usesubusernamefordefaultidentityclaim": true,
            "usefieldnameforprimarykeyconnectionfield": false,
            "enableautoindexquerynames": true,
            "respectprimarykeyattributesonconnectionfield": true,
            "shoulddeepmergedirectiveconfigdefaults": false,
            "populateownerfieldforstaticgroupauth": true
        },
        "frontend-ios": {
            "enablexcodeintegration": true
        },
        "auth": {
            "enablecaseinsensitivity": true,
            "useinclusiveterminology": true,
            "breakcirculardependency": true,
            "forcealiasattributes": false,
            "useenabledmfas": true
        },
        "codegen": {
            "useappsyncmodelgenplugin": true,
            "usedocsgeneratorplugin": true,
            "usetypesgeneratorplugin": true,
            "cleangeneratedmodelsdirectory": true,
            "retaincasestyle": true,
            "addtimestampfields": true,
            "handlelistnullabilitytransparently": true,
            "emitauthprovider": true,
            "generateindexrules": true,
            "enabledartnullsafety": true,
            "generatemodelsforlazyloadandcustomselectionset": false
        },
        "appsync": {
            "generategraphqlpermissions": true
        },
        "latestregionsupport": {
            "pinpoint": 1,
            "translate": 1,
            "transcribe": 1,
            "rekognition": 1,
            "textract": 1,
            "comprehend": 1
        },
        "project": {
            "overrides": true
        }
    },
    "debug": {}
}

@ykethan ykethan added the pending-response An issue is pending response from the issue requestor label Nov 28, 2023
@fistofzen
Copy link
Author

Hello, when I replace the cli.json I am getting error when I "amplify push" as below.

Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
⠹ Uploading files.🛑 EMFILE: too many open files, open '/Users/XXXX/Technology_Works/XXX/amplify/backend/api/XXX/build/states/initial-stack/resolvers/Workout.muscleGroups.req.vtl'

Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
⠏ Uploading files.🛑 Inaccessible host: amplify-XXXXXX-rescued-223335-deployment.s3.eu-central-1.amazonaws.com' at port undefined'. This service may not be available in the `eu-central-1' region.

@github-actions github-actions bot removed the pending-response An issue is pending response from the issue requestor label Nov 28, 2023
@fistofzen
Copy link
Author

Hello,
After adding the line "enableAutoIndexQueryNames" everything worked.
Before the amplify version is older but later I upgraded it. How can I also update cli.json file ? Is there a command for it ?

@ykethan
Copy link
Member

ykethan commented Nov 29, 2023

Hey @fistofzen, typically running amplify update for a resource should prompt you to migrate a resource if built on a older version of cli and and update it. updating the cli.json file and running push should update the resource as well.
But diving into the error message it appears to be occurring on a API resource resolver files, i have forwarded the GitHub issue open on the CLI repository to the API repository for further investigation.

@ykethan ykethan added the pending-response An issue is pending response from the issue requestor label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-response An issue is pending response from the issue requestor studio-ui An issue that needs to be tracked by Studio Console team ui-forms issues related to UI builder forms
Projects
None yet
Development

No branches or pull requests

2 participants