Hello,
How can I have a subscription notification message (upon an update) include the full relation data in a many-to-many relation?
I have a many-to-many relations using the Amplify @model and @connection directives, as it is documented in the Amplify docs. In this case, I have a Person and City entities, where one person can belong to many cities, and one city can belong to many persons. To model this, I have a PersonCity connecting entity.
For queries, I am able to fetch all the cities for a person with a custom GraphQL query, which I pass to the graphqlOperation() function.
My problem is that I also want the cities returned via subscription messages when the Person is updated (for instance, a new city is added). Currently, I only receive City ID in the cities array inside Person. However, I want the subscription message to return all the City fields as well, e.g. name.
Any help would be greatly appreciated.
This is the general schema I'm working with:
type Person @model
{
id: ID!,
cities: [PersonCity] @connection(name: "PersonCities")
}
type City @model
{
id: ID!
name: String!
persons: [PersonCity] @connection(name: "CityPersons")
}
type PersonCity @model(queries: null)
{
id: ID!
person: Person! @connection(name: "PersonCities")
city: City! @connection(name: "CityPersons")
}