Solved

[FDM] How to filter custom array properties in a GraphQL query

  • 9 August 2023
  • 4 replies
  • 79 views

Badge +5

I have some views with simple array properties (arrays of primitives) and others with arrays of relationships to views (edges).

Location view

I can filter the simple arrays with the “containsAll” or “containsAny” methods.

But there seems to not be a filter avaiable for the edges in the Graphql API.

 

How can I filter by these properties via the GraphQL API?

icon

Best answer by mattmurph9 11 August 2023, 20:45

View original

4 replies

We currently don’t support filtering on properties of related nodes from a 1:many relationship. But we do support filtering on properties that are related in a 1:1 relationship.

Though if you instead query for the related type (say Role from your above types), and add a 1:1 relation back to the ‘parent’ (User in this case), you can then filter on properties of the User and Role. So the Role type and query would become
 

type Role {
...
user: User
}


{
listRole(filter: { and: [ { ...some filter on properties of Role }, { user: { ...some filter on properties of User } } ] }) {
items {
externalId
roleName
user {
externalId
}
}
}
}

 

Userlevel 3

Hi @Lucas Carvalho de Sousa, did the above help?

Badge +5

Hello @Carin Meems, it helped understand that what I wanted to do is not possible right now, but it its a possible workaround that I am investigating

Reply