Is there a known issue with filtering Many-To-Many relations? #1285
-
Im using version 0.28.1 and noticed I'm not able to use filters on a Many-to-Many relation In this example the Role entity and the Security entity have a Many-to-Many relationship. The GraphQL query returns all the securities regardless of the filter. Role @FilterableUnPagedRelation('securities', () => Security)
@ManyToMany(() => Security)
@JoinTable({ name: 'role_security' })
securities: Security[]; Security @FilterableUnPagedRelation('roles', () => Role)
@ManyToMany(() => Role)
@JoinTable({ name: 'role_security' })
roles: Role[]; query {
roles(
filter: { securities: { type: { eq: "UI" } } }
) {
edges {
node {
id
users {
id
username
}
securities {
id
scope
type
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Omg...... I don't know if this documented anywhere but I guess I've just been using the filtering wrong. I didn't realize you could add the query arguments multiple layers in on the relationship. Fixed Query below query {
roles {
edges {
node {
id
users {
id
username
}
securities (filter: { type: { eq: "UI" } } {
id
scope
type
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi @DarkHiveCreations So far I have managed to get the many-to-one relationship with JoinColumn to work. But the many-to-many is not inserting anything into the JoinTable. Grateful for any hints or advice 🙏🏼 |
Beta Was this translation helpful? Give feedback.
Omg...... I don't know if this documented anywhere but I guess I've just been using the filtering wrong. I didn't realize you could add the query arguments multiple layers in on the relationship.
Fixed Query below