* Which Category is your question related to? *
DataStore
* What AWS Services are you utilizing? *
AWS AppSync
The @connection GraphQL Transform docs recommend "defining index structures using @key and connection resolvers using @connection" over the older alternative definition.
However the DataStore docs only make mention of this apparently obsolete alternative @connection directive.
Which is preferred for using DataStore? Are the docs simply outdated, or is the alternative @connection directive indeed the preferred way here?
Hi @AndrewPrifer
The recommended way mentioned in the GraphQL Transform docs is indeed the way we recommend you define relations between your models.
I will work on updating the DataStore docs.
Thanks @Ashish-Nanda
@Ashish-Nanda Following the recommended way as described in the docs is giving me the following error:
DataStore does not support connection directive with keyName
CLI version: @aws-amplify/[email protected]
With the following schema:
type Post
@model
@auth(rules: [
{ allow: owner, identityClaim: "email" },
{ allow: groups, groups: ["Admin"] }
])
{
id: ID!
name: String
comments: [Comment] @connection(keyName: "byPost", fields: ["id"])
}
type Comment
@model
@auth(rules: [
{ allow: owner, identityClaim: "email" },
{ allow: groups, groups: ["Admin"] }
])
@key(name: "byPost", fields: ["postId"])
{
id: ID!
name: String
postId: ID!
}
Should I use the way as described in the DataStore section, and use "name" instead?
after upgrading CLI to
CLI version: @aws-amplify/[email protected]
I received this error:
DataStore does not support connection directive with keyName
Most helpful comment
Hi @AndrewPrifer
The recommended way mentioned in the GraphQL Transform docs is indeed the way we recommend you define relations between your models.
I will work on updating the DataStore docs.