amplify-category-api icon indicating copy to clipboard operation
amplify-category-api copied to clipboard

Generates twice the connection ID

Open juri-diener opened this issue 1 year ago • 3 comments

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

20.6.1

Amplify CLI Version

11.0.5

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

type User @model @auth(rules: [{ allow: private }]) {
  id: ID!
  name: String
  myOrg: Org @hasOne
  orgs: [Org] @manyToMany(relationName: "OrgUser")
}

type Org
  @model
  @auth(
    rules: [
      { allow: private, operations: [read] }
      { allow: groups, groups: ["Admins"] }
    ]
  ) {
  id: ID! @primaryKey(sortKeyFields: ["userID"])
  name: String!
  userID: ID!
  users: [User] @manyToMany(relationName: "OrgUser")
  user: User @belongsTo(fields: ["userID"])
}

So if I have this models with the relation ships. It creates for the createUserInput following:

id: ID
name: String
userMyOrgId: ID
userMyOrgUserID: ID

This is related both to the myOrg:Org @hasOne relation. If I remove the entire line, then both userMyOrgId and userMyOrgUserID are gone.

As well for the between model which are created automatically has the same issue.

createOrgUser(condition: ModelOrgUserConditionInputinput: CreateOrgUserInput!): OrgUser
CreateOrgUserInput: 
id: ID
userId: ID!
orgId: ID!
orguserID: ID!

And I different problem: So when I add an item in OrgUser. Provide the orgId, orguserID with the orgId and the userId with the userId. And then query the user I got null.

query MyQuery {
  getUser(id: "someID") {
    orgs {
      items {
        org {
          name
        }
      }
    }
  }
}

If I remove the hasOne relation then it works. But this is a common pattern. That a user as one org because he is the owner and user can be part of multiple orgs and org can have multiple user.

Expected behavior

For createUserInput:

id: ID
name: String
userMyOrgUserID: ID

For CreateOrgUserInput:

id: ID
userId: ID!
orgId: ID!

Reproduction steps

Create the model and push it with amplify push -y

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

juri-diener avatar Apr 06 '24 09:04 juri-diener

Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂

ykethan avatar Apr 08 '24 15:04 ykethan

Hi @juri-diener, My apologies for the delayed response. Could you provide more details on the relationships between 'user' and 'org'? Can a 'user' be associated with multiple 'orgs'?

AnilMaktala avatar May 03 '24 17:05 AnilMaktala

Hi @juri-diener, I can reproduce the issue by following the details in the description. Hence, marking this as a bug for the team to evaluate further.

image

AnilMaktala avatar May 06 '24 13:05 AnilMaktala

Hi @juri-diener, I can reproduce the issue by following the details in the description. Hence, marking this as a bug for the team to evaluate further.

image

Hi, ok that's good any update on this?

juri-diener avatar Jun 06 '24 17:06 juri-diener