Is your feature request related to a problem? Please describe.
Using @connection with keyName is complex and using it with name requires extra naming work and its deletion behavior can be ambiguous. I've thought of a different approach that may be simpler, not sure.
Describe the solution you'd like
Maybe something like:
@connection(reverseProperty: String!, propagateDeletion: Boolean!)
And possibly a convenience directive:
@connection(propagateDeletion: Boolean!)
The term reverseProperty could also be inverseProperty, but either would make sense I think.
With this approach you don't need to think about:
Multiplicity and optionality are specified in the normal way ([], !), and many-to-many relationships can either be explicit (using [] at both ends) or implicit (using two one-to-many relationships like can be done now).
I think it might make the model easier to reason about too. I haven't worked through it thoroughly or anything, just curious what people think.
Example:
type PhoneCall @model {
id: ID!
caller: Person! @connection(reverseProperty: "callerOf", propagateDeletion: false)
callee: Person! @connection(reverseProperty: "calleeOf", propagateDeletion: false)
}
type Person @model {
id: ID!
name: String!
callerOf: [PhoneCall!] @connection(reverseProperty: "caller", propagateDeletion: true)
calleeOf: [PhoneCall!] @connection(reverseProperty: "callee", propagateDeletion: true)
}
After some months now building schemas I still struggle to get my head around all the combinations that you can use @connection and it still comes back to bite me once in a while. I'm forever having to re-read the doc https://docs.amplify.aws/cli/graphql-transformer/connection but I still don't find that its as easy to read and understand as it could be (testiment to me having to continually re-read all the differences).
I'm all for this getting some attention and fresh thought as currently its a bit of a trap for developers. I'd hoped that the new Admin UI would help visualise all these but while trying to get an existing schema in there I've had to add DataStore which is now throwing up errors including the aws-amplify/amplify-ios#505 which is what brought me here. The comments in that issue and my own experience lead to me think that trying to fix issues with the schema come down to "try removing stuff!" until it works rather than really understanding it, I thought I understood it but then I his that 1-to-1 error and I'm stumped.
Most helpful comment
After some months now building schemas I still struggle to get my head around all the combinations that you can use @connection and it still comes back to bite me once in a while. I'm forever having to re-read the doc https://docs.amplify.aws/cli/graphql-transformer/connection but I still don't find that its as easy to read and understand as it could be (testiment to me having to continually re-read all the differences).
I'm all for this getting some attention and fresh thought as currently its a bit of a trap for developers. I'd hoped that the new Admin UI would help visualise all these but while trying to get an existing schema in there I've had to add DataStore which is now throwing up errors including the aws-amplify/amplify-ios#505 which is what brought me here. The comments in that issue and my own experience lead to me think that trying to fix issues with the schema come down to "try removing stuff!" until it works rather than really understanding it, I thought I understood it but then I his that 1-to-1 error and I'm stumped.