GraphQL Query $where Clause Example

default discord avatar
freakyfriday
last year
1 1

Hello,

I'm trying to query using the $where clause but am receiving a typed error. I'm following the example at https://payloadcms.com/docs/queries/overview#graphql-find-queries but still can't figure out why the type conversion is failing.

Playground Query:

Screen Shot 2022-05-26 at 2 20 13 pm

Types:

Screen Shot 2022-05-26 at 2 22 31 pm

Any assistance would be greatly appreciated :-)

Thanks

  • default discord avatar
    freakyfriday
    last year

    If anyone is following I figured it out. I had to change the type of $where from JSON to Post_where:

    Screen Shot 2022-05-26 at 2 37 26 pm

    1 reply
  • discord user avatar
    jmikrut
    Payload Team
    last year

    @freakyfriday — I can do you one better.

    While your syntax DOES work, the better way would be like this:

    image

    No $ needed. Just use the where argument!

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.