aws-amplify / aws-amplify/amplify-data
Add a way to export the backend schema when working with separate Frontend and Backend repos
- Dominant language
- TypeScript
- Stars
- 18
- Forks
- 23
- Avg merge
- 26m
- Merged PRs (30d)
- 1
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
```shell
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 failed
```
## Describe 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](https://docs.amplify.aws/react/reference/cli-commands/#npx-ampx-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](https://repost.aws/questions/QUs7MwF7bGQluD8WlPV1pzXQ/how-to-use-clientextensions-accessors-and-methods-in-amplify-gen2-app-with-separate-backend-frontend) 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: https://github.com/aws-amplify/docs/issues/7577 so that you can see this is a problem affecting multiple users.
Contributor guide
Research direction
Start by reading the documented generate-graphql-client-code command and the linked multi-repository schema guidance, then compare their behavior with the deployment failure shown here. Done means a documented command or extension can obtain the deployed backend schema and generate usable client types for a separate frontend repository.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- api, developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100