I'm needing to create a searchable listing table where some records are of type ORGANIZATION
or RESOURCE
. The relationshipis one-to-many. So, an Organization can have many Resources. How can I create this relationship under one model?
Using AWS Amplify GraphQL API...
Like this? schema.graphql
enum ListingType {
ORGANIZATION
RESOURCE
}
type Listing @model {
id: ID!
title: String!
type: ListingType!
orginzation: Listing
}
Yet, in Mutations, I can't reference a parent organization when creating my first Resource:
You need to include a @connection
directive for any field that is a relationship, as outlined in the docs. In this case, something like this should work:
type Listing @model {
id: ID!
title: String!
type: ListingType!
organization: Listing @connection
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With