-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Issue generating client Schema with separate repos
When working with separate frontend and backend repositories, we need a way to import the backend schema to run 'generateClient' with and be able to use the client options, autocomplete, type safety, etc.
The Amplify documentation says to 'clone' the backend repo in the same parent location as the frontend and add an alias to the tsconfig.json file, but of course this does not work when deployed: https://docs.amplify.aws/nextjs/deploy-and-host/fullstack-branching/mono-and-multi-repos/#sharing-schema-type-definitions
2025-08-29T03:49:32.043Z [WARNING]: Failed to compile.
2025-08-29T03:49:32.048Z [WARNING]: ./src/lib/actions.ts:1:29
Type error: Cannot find module '@/data-schema' or its corresponding type declarations.
�[0m�[31m�[1m>�[22m�[39m�[90m 1 |�[39m �[36mimport�[39m type { �[33mSchema�[39m } �[36mfrom�[39m �[32m"@/data-schema"�[39m
�[90m |�[39m �[31m�[1m^�[22m�[39m
�[90m 2 |�[39m �[36mimport�[39m { generateClient } �[36mfrom�[39m �[32m"aws-amplify/data"�[39m
�[90m 3 |�[39m �[36mimport�[39m { �[33mAmplify�[39m } �[36mfrom�[39m �[32m'aws-amplify'�[39m�[33m;�[39m
�[90m 4 |�[39m �[36mimport�[39m outputs �[36mfrom�[39m �[32m'@amplify_outputs.json'�[39m�[33m;�[39m�[0m
2025-08-29T03:49:32.066Z [WARNING]: Next.js build worker exited with code: 1 and signal: null
2025-08-29T03:49:32.115Z [ERROR]: !!! Build failedDescribe the solution you'd like
There should be a command that can be run when the app is deployed and that allows us to generate the client Schema based on the deployed version of the backend. This will allow us to add this command to the deployment script and make sure we are always getting the latest version of the schema.
There is a similar command called generate-graphql-client-code which for some reason does not fulfill this need, even through it looks like it could be the right solution.
I suggest either adding this functionality to the existing generate-graphql-client-code or creating a new command to achieve this.
Describe alternatives you've considered
Digging trough the internet, I found a question on AWS re:Post that had a response generated by AI that suggested that the resource.ts file from the backend should be copied to the frontend repo everytime there is change on the backend. This seems like a really inelegant solution that requires us to create some sort of automation to keep the two repos in sync, which will have to involve extra steps outside of the Amplify pipeline.
Additional context
Please see the following issue raised by other Amplify users: aws-amplify/docs#7577 so that you can see this is a problem affecting multiple users.