Is it possible to use Calculated Value in GraphQL Filter? #7723
-
We're using a Calculated Value in an Object. The value is calculated from a Many-To-One Relation. We are checking to see if the object associated by the Many-To-One Relation is published. The Calculated Value is working properly, we can see the correct value in the GraphQL Object Listing response. Using GraphQL we can SortBy the Calculated Value when the "Indexed" option is checked in the class definition. When trying to use the Calculated Value as part of a GraphQL Filter it does not work, for example: filter: "{"ispublished": "yes"}" and filter: "{"ispublished": {"$not": "yes"}}" both return no results. We are able to filter by other fields, such as Inputs and Text Areas. Is it possible to use a Calculated Value as part of a GraphQL Filter? If so, are there any examples of how to go about doing it? Any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
Hi @mjnewman , can you provide a complete query example here please ? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi @weisswurstkanone please find the query example below. I've removed some of the extraneous elements, but this should give a good example of what we're trying to do. The Calculated Value ispublished is calculated from the lookupobject->getPublished() value and is populated with the string "true" or "false". With ispublished "Indexed" the SortBy/SortOrder is working. With "Indexed" unchecked SortBy/SortOrder does not appear to work. The filter shown in the query returns no errors and a result of "edges": []. Without the filter, the query returns the expected results. We're using DataHub version 0.6.3. Thanks! { |
Beta Was this translation helpful? Give feedback.
-
For the listings the query table is used. Although it says "calculated value" you have to at least save the object to populate the table. |
Beta Was this translation helpful? Give feedback.
-
Currently not supported as many-to-one occupies 2 columns in the query table. |
Beta Was this translation helpful? Give feedback.
-
Maybe the Pimcore\Bundle\DataHubBundle\Event\GraphQL\Model\ListEvent could be helpful which is fired before the list eventually gets loaded. never used it though |
Beta Was this translation helpful? Give feedback.
For the listings the query table is used. Although it says "calculated value" you have to at least save the object to populate the table.
If you just call the getter, then it will be calculated on the fly of course.