aws-amplify / aws-amplify/amplify-codegen

[feature request] Add join table identification to the introspection schema

Open
#543 0 comments 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
TypeScript
Stars
59
Forks
64
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-codegen/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-codegen/blob/main/CONTRIBUTING.md#bugs).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### How did you install the Amplify CLI?

_No response_

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

_No response_

### Amplify CLI Version

10.7.3

### What operating system are you using?

Mac

### Amplify Codegen Command

other `codegen ` (please mention in the issue)

### Describe the bug

*This is a feature request*

Currently, there is no 100% sure way of telling whether a model is a join table from the introspection schema.

**Definition of "join table" here:**
Given the schema:
```
type User @model {
id: ID!
Entries: [Entry] @hasMany(indexName: "byUser", fields: ["id"])
Images: [Image] @hasMany(indexName: "byUser", fields: ["id"])
Dogs: [Dog] @manyToMany(relationName: "UserDog")
}

type Entry @model {
id: ID!
userID: ID! @index(name: "byUser")
User: User @belongsTo(fields: ["userID"])
Images: [Image] @hasMany(indexName: "byEntry", fields: ["id"])
}

type Image @model {
id: ID!
userID: ID! @index(name: "byUser")
entryID: ID! @index(name: "byEntry")
User: User! @belongsTo(fields: ["userID"])
Entry: Entry! @belongsTo(fields: ["entryID"])
}

type Dog @model {
Users: [User] @manyToMany(relationName: "UserDog")
}
```

`UserDog` should be identified as a join table and `Image` should not be.

### Expected behavior

*Request:*
In the schema produced by running `amplify codegen model-introspection --output-dir example`...

1. Mark join table models with a property like `isJoinTable: true`
2. Add an identification to the model introspection schema so that it can be distinguished from a) the MIPR and b) previous versions of itself. Example: `isIntrospection: true`, `version: 1.1.0` (or does the `version` field there currently already serve as this indicator?)

### Reproduction steps

N/A

### GraphQL schema(s)

_No response_

### Log output

_No response_

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.