aws-amplify / aws-amplify/amplify-data

Add a way to export the backend schema when working with separate Frontend and Backend repos

Open
#621 3 comments 1 reaction 0 assignees View on GitHub
feature-request question
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.

> 1 | import type { Schema } from "@/data-schema"

 | ^

 2 | import { generateClient } from "aws-amplify/data"

 3 | import { Amplify } from 'aws-amplify';

 4 | import outputs from '@amplify_outputs.json';

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.