FSharp.Data.GraphQL icon indicating copy to clipboard operation
FSharp.Data.GraphQL copied to clipboard

Filter for root properties

Open StefanBelo opened this issue 5 years ago • 5 comments

I am having problems to create filter for root property, something like that:

query {
    markets (filter : { totalMatched_greater_than : 1000.0 }) {
        id
        name
        totalMatched
        status
        requestTime
        updateTime
        selections (filter : { totalMatched_greater_than : 1000.0 }) {
            id
            name
            lastPriceTraded
            totalMatched
            status
        }
    }
}

In the code base there is actually no example of such usage. Maybe I am wrong because I just read something about graphQL and trying to implement that in my use case scenario.

StefanBelo avatar Aug 02 '20 10:08 StefanBelo

@StefanBelo were you able to find a solution?

festim-deari avatar Jun 14 '22 12:06 festim-deari

What happens when you do that?

xperiandri avatar Jun 14 '22 16:06 xperiandri

Does it work for nested fields?

xperiandri avatar Jun 14 '22 16:06 xperiandri

Hi @xperiandri, sorry for replying late.

This is my middlewares definition: let middlewares = [ Define.ObjectListFilterMiddleware<Root.Root, Label>(true)]

Root.Root is the ObjectType for the QueryRoot. It has a field called labels of type Label list.

When I try to filter in the query as follows: query { labels (filter: {annotation_sw: "Cu"}) { annotation id } }

It throws the error : "Argument field or value named 'filter' can not be coerced. It does not match a valid literal representation for the type."

festim-deari avatar Jun 16 '22 17:06 festim-deari

Does it work for nested fields?

Yes it does in my case. I tried it for a nested field which is also a list, and it works perfectly.

festim-deari avatar Jun 16 '22 17:06 festim-deari