Skip to content
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

Unable to create many-to-many relationship with self-related model #1303

Closed
matthieunelmes opened this issue Apr 17, 2019 · 2 comments
Closed
Assignees
Labels
graphql-transformer-v1 Issue related to GraphQL Transformer v1 pending-triage Issue is pending triage

Comments

@matthieunelmes
Copy link

Describe the bug
As many-to-many relationships are not natively supported with Amplify annotated graphql connections, I've managed to create my own with the solution listed #91 (comment)

My issue is I would like to create a many-to-many relationship with a self-related model.
For instance, a User who has multiple friends which are of the type User.

Using the connection annotation, I would expect to be able to use something like:

type User @model{
    id:ID!
    name:
    friends: [UserFriend] @connection(name: "UserFriends")
}

type UserFriend @model{
    id: ID!
    user: User @connection(name: "UserFriends")
}

This compiles the graphQL schema without error, but when pushing to Amplify this throws
Only one resolver is allowed per field.

@UnleashedMind UnleashedMind added graphql-transformer-v1 Issue related to GraphQL Transformer v1 pending-triage Issue is pending triage labels Apr 17, 2019
@matthieunelmes
Copy link
Author

Turns out this schema works fine, my issue was with old resolvers not being deleted with tables. So it was a situation where an orphaned resolver was re-attaching to what I presumed to be a newly created table. Then when I tried to re-connect with the @connection annotation, a resolver was already in place, hence the error.

This is linked to #682

@github-actions
Copy link

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 *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
graphql-transformer-v1 Issue related to GraphQL Transformer v1 pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

3 participants