-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataStore does not support connection directive with keyName #3909
Comments
I am having the same issue even though it was suggested here that it should work, and that the docs for DataStore are outdated. |
The responsible code for this is here. I implemented this fix on my own as an experiment before finding this issue, and I can confirm that with this fix, the resulting models and schemas are generated fine.
But of course I have no clue whether this is actually supported or not and whether something will break somewhere else down the line. |
Just noting that in my previous comment I believed this to be limiting because I believed this was the only way to implement M-M connections. However, I was misled by the new docs as they had two sections, one of which uses keyName and another which does not. |
after upgrading amplify CLI to version: @aws-amplify/cli@4.18.1 |
The DataStore client libraries never supported keyName, and model gen did not flag this. We updated the model gen to throw this as an error so that there are no surprises at later at run time. |
I'm still confused on the recommended way to do many-to-many relationships when we want Datastore support.
I understand this is a complex issue, leading to several breaking changes. Keep up the great work! This library makes AWS much more accessible. |
@yuth is there an open issue tracking this future feature that we can track? |
Kind of confusing, I thought the DataStore is designed for working with Graphql API. Or, it is WIP? |
@Albert-Gao it can be confusing, but it is in fact supported by the legacy (and future-outdated I'd suggest looking at the docs here and using the soon-to-be-deprecated
|
@blydewright Thanks, now I have a working example now. :) But won't progress far since the issue here. This is my 2nd try of Amplify, always stuck from the start for some feature. Hope this time it goes well. |
@Albert-Gao I also have run into many issues, however most of them seem to have been me doing this the wrong way. I think some better documentation steps, especially showing the ideal flow and process for setting things up in live and mock environments, would really help! But the AWS guys seem to be overloaded which is understandable. @Albert-Gao I managed to sort out the issue with the I've confirmed that there are definitely issues with DataStore in the mock environment. Better for you to run things in AWS cloud for now while these are addressed. aws-amplify/amplify-category-api#322 |
Can you take a look at the latest docs for Relational modeling with DataStore and use the latest library version? We made some improvements to the CLI, the library on how it handles this internally, and tried to be explicit about schemas in the documentation including how to use |
Does the field have to be named id or can it just be an ID field? Would this work: enum PostStatus {
ACTIVE
INACTIVE
}
type Post
@model
@key(fields: ["postID"])
{
postID: ID!
title: String!
rating: Int!
status: PostStatus!
# New field with @connection
comments: [Comment] @connection(keyName: "byPost", fields: ["postID"])
}
# New model
type Comment @model
@key(fields: ["commentID"])
@key(name: "byPost", fields: ["postID", "content"]) {
commentID: ID!
postID: ID!
content: String!
} |
As long as the key has a name, it can be anything. But if the name property is omitted, the first item in the fields array must be “id”. |
I updated to Amplify 4.20.0 with the following command. It works |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Which Category is your question related to?
Datastore
Amplify CLI Version
4.18.0
What AWS Services are you utilizing?
API, Cognito
Provide additional details e.g. code snippets
Following schema used to work. But doesn't work anymore.
Now if I do
amplify codegen models
I get following errorError: DataStore does not support connection directive with keyName
My question is
"Is this permanant change? or you have plans to support connection directive with keyName for datastore in future?"
The text was updated successfully, but these errors were encountered: