Skip to content

Relational models saving relations example is broken #5168

@david-mcafee

Description

@david-mcafee

Describe the content issue:
A clear and concise description of what the content issue is. Is there content missing or is there incorrect content?
See the following updated schema as described in the docs:

enum PostStatus {
  ACTIVE
  INACTIVE
}

type Post @model {
  id: ID!
  title: String!
  rating: Int!
  status: PostStatus!
  # New field with @hasMany
  comments: [Comment] @hasMany(indexName: "byPost", fields: ["id"])
}

# New model
type Comment @model {
  id: ID!
  postID: ID! @index(name: "byPost")
  post: Post! @belongsTo(fields: ["postID"])
  content: String!
}

You’ll notice that Comment has a required postID, as well as a required post. This means when we save the Comment, both the instance and postID are required.

As of now, if a customer uses the code samples in the docs with this schema, they’ll get type errors (i.e. that postId is required when using this code example).

URL page where content issue is:
https://docs.amplify.aws/lib/datastore/relational/q/platform/js/#saving-relations

Metadata

Metadata

Labels

DataStoreDocumentation dealing with the DataStore, can be for any/all platform(s)amplify/dataIssue related to aws-amplify/amplify-category-apip2incorrect info. ie a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions