Skip to main content
Solved

How to filter null values of FDM view's inherent property in GraphQL


Hi Team,

In GraphQL there is no (known) option to filter null values of FDM View’s direct properties which refer to another view(s).

For example: Consider the snapshot of the views.

Here if we want to filter all MyTypeWrapper instances which has ‘myType’ property as null.

How could it be achieved using GraphQL?

-Mohit

Best answer by Jason Dressel

@Mohit Shakaly
myType is a directRelation.  It’s type is defined by a (space, externalId) tuple. 

Apologies for the very delayed reply.   I’m using the null of the externalId as a measure of ‘null’ with respect to the direct relation.

1# Based on the following model derived from the Actor/Movie example:
2
3
4type PersonType @view(space: "test", version: "1") {
5 typename: String!
6}
7
8interface Person @view(space: "test", version: "1") {
9 typename: PersonType
10 name: String!
11 age: Int
12}
13
14#populate your Actors with 'actor' as the PersonType, do not populate the Directors with any typename
15
16# using the following graphQL query, you'll get just 'Director' Persons
17query MyQuery {
18  listPerson(filter: {typename: {externalId: {isNull: true}}}) {
19    items {
20      name
21      typename {
22        typename
23      }
24    }
25  }
26}

 

 

fyi @Dilini Fernando 

View original
Did this topic help you find an answer to your question?

3 replies

Dilini Fernando
Seasoned Practitioner
Forum|alt.badge.img+2

Hi @Mohit Shakaly,

I have created a Support ticket, then our team can follow up and help you. 

Best regards,
Dilini


Forum|alt.badge.img
  • Seasoned Practitioner
  • 294 replies
  • Answer
  • July 18, 2023

@Mohit Shakaly
myType is a directRelation.  It’s type is defined by a (space, externalId) tuple. 

Apologies for the very delayed reply.   I’m using the null of the externalId as a measure of ‘null’ with respect to the direct relation.

1# Based on the following model derived from the Actor/Movie example:
2
3
4type PersonType @view(space: "test", version: "1") {
5 typename: String!
6}
7
8interface Person @view(space: "test", version: "1") {
9 typename: PersonType
10 name: String!
11 age: Int
12}
13
14#populate your Actors with 'actor' as the PersonType, do not populate the Directors with any typename
15
16# using the following graphQL query, you'll get just 'Director' Persons
17query MyQuery {
18  listPerson(filter: {typename: {externalId: {isNull: true}}}) {
19    items {
20      name
21      typename {
22        typename
23      }
24    }
25  }
26}

 

 

fyi @Dilini Fernando 



Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings