My Products
Help
PectorDeveloper
CONTRIBUTOR *

Filter on fields not in the items part

by PectorDeveloper

Hi is it possible to filter on fields that you don't want to include in the output ?

 

example:

 

query
{
    useCompany(no: 9999)
    {
        queryResult : orderDocument
        (
            filter: 
			{
				_and :
				[
					{requiredDeliveryDate : {_gt:20230801}},
					{picListNo :{_in:[1,3,6]}}
				]
			}      
		)
        {
            totalCount
            items
            {
                orderNo
                orgUnit3
                customerNo
                deliveryAddress1
                deliveryAddress2
                deliveryAddress3
                deliveryAddress4
            }
        }
    }  
}

 

In the above example I am not selecting the requiredDeliveryDate  or the picListNo in the output, can I still filter on these fields ?

1 REPLY 1
Accepted solution
omelhus
PARTNER

by omelhus

Yes, what you put in the filter does not affect the data you want to retrieve. In fact you can have the filter as a parameter and still fetch the data you are after.

 

query findDocuments($cid: Int!, $filter: FilterExpression_OrderDocument) {
  useCompany(no: $cid) {
    queryResult: orderDocument(filter: $filter) {
      totalCount
      items {
        orderNo
        orgUnit3
        customerNo
        deliveryAddress1
        deliveryAddress2
        deliveryAddress3
        deliveryAddress4
      }
    }
  }
}

 

And then pass the following params:

 

{
   "cid":99999,
   "filter":{
      "_and":[
         {
            "requiredDeliveryDate":{
               "_gt":20230801
            }
         },
         {
            "picListNo":{
               "_in":[
                  1,
                  3,
                  6
               ]
            }
         }
      ]
   }
}