npx ampx generate graphql-client-code --model-target typescript --out graphql generates schema generates different schema. #2506
Labels
pending-response
Issue is pending response from author
pending-triage
Incoming issues that need categorization
transferred
Issue was transferred from another Amplify repository
Environment information
Data packages
Description
Hello Community,
I have recently discovered that when I run
npx ampx generate graphql-client-code --model-target typescript --out graphql
in the amplify app directory it generates the code for the schema from amplify/data/resource.ts from the last deployed sandbox stack in the local system.This is the documentation for the code
[+] https://docs.amplify.aws/react/reference/cli-commands/#npx-ampx-generate-graphql-client-code
How i observed the issue
[+] https://docs.amplify.aws/react/start/quickstart/
npx ampx generate graphql-client-code --model-target typescript --out graphql
To my surprise the code was taking schema from entirely different amplify application. I have verified the current working directory by 'pwd' and it was the correct directory.
Later i could observe that it is taking the last deployed schema from the last deployed sandbox in the machine.
To further verify the observation and replication steps
[+] https://docs.amplify.aws/react/start/quickstart/
'npx ampx sandbox'
npx ampx generate graphql-client-code --model-target typescript --out graphql
Later after deep dive, I could observe that the the app name in the package.json is same for both the application "amplify-vite-react-template".
CLI uses the package name in package.json to generate sandbox identifiers. If two projects accidentally share the same package name, it can cause some sandbox identifier conflicts.
Amplify recommends using the amplify quick start template, but if a user is creating a multiple apps in the system, it can cause this strange behavior as all the apps will have the same name if created from the quickstart template and the generate code will take the last deployed sandbox stack instead of the local file.
This should be clear in the documentation or amplify docs should recommend installing the app manually instead of using templates which can cause this type of behavior.
Thank you
The text was updated successfully, but these errors were encountered: