aws-sdk-js icon indicating copy to clipboard operation
aws-sdk-js copied to clipboard

Vague descriptions of @manyToMany behavior in documentation

Open remyhunt opened this issue 3 years ago • 1 comments

Describe the issue

@manyToMany - Configures a "join table" between two models to facilitate a many-to-many relationship. For example, a Blog has many Tags and a Tag has many Blogs.

Under the hood, the @manyToMany directive will create a "join table" named after the relationName to facilitate the many-to-many relationship. This generates queries and mutations that allow you to retrieve the related Comment records from the source Post record and vice versa

Can we be more specific on what how the join table is configured? Phrases like "under the hood" and "configures..." leave me wondering what is happening behind the scenes. What it sounds like to mei s that a DynamoDB table is being generated. If it's generating that table, where do we store the relations? Should we explicitly make that join table and store them there like a relational db?

In the following examples from the documentation: https://docs.amplify.aws/cli/graphql/data-modeling/#many-to-many-relationship

type Post @model {
  id: ID!
  title: String!
  content: String
  tags: [Tag] @manyToMany(relationName: "PostTags")
}

type Tag @model {
  id: ID!
  label: String!
  posts: [Post] @manyToMany(relationName: "PostTags")
}

Are posts and tags attributes which are populated in our database with an array of... what? Would it be a group of type String in our DynamoDB, where each is the default primary key, aka the id of Post?

Links

https://docs.amplify.aws/cli/graphql/data-modeling/#many-to-many-relationship

remyhunt avatar Aug 31 '22 19:08 remyhunt

Hey @remyhunt thanks for opening this issue but its not related to JS SDK, can you please open this at https://github.com/aws-amplify/amplify-cli

ajredniwja avatar Sep 07 '22 08:09 ajredniwja