Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Search block fields

default discord avatar
christopher.nowlan3 years ago
9

Is there a way to query in GraphQl if a block contains a string value

  • default discord avatar
    jessrynkar3 years ago

    bump

  • discord user avatar
    jmikrut
    3 years ago

    Not in GraphQL there isn't, due to the strict typing necessary for GraphQL inputs. But this is an open roadmap item



    right now, you could use the REST API and dot notation to search on block fields



    there are a few discussions open re: how to do this

  • default discord avatar
    christopher.nowlan3 years ago

    Do you know if anyone has done this yet?

  • discord user avatar
    jmikrut
    3 years ago

    in graphql? or REST?

  • default discord avatar
    christopher.nowlan3 years ago

    REST

  • discord user avatar
    jmikrut
    3 years ago

    in REST you certainly can



    https://github.com/payloadcms/payload/discussions/852

    take a read through this



    it's not exacxtly the same as to what you're asking, but the principle is the same



    you can create dot-notation based nested field where queries

  • default discord avatar
    christopher.nowlan3 years ago

    Thanks

    @364124941832159242

    I'll have a look



    Does the above only work in the CMS?

  • discord user avatar
    jmikrut
    3 years ago

    what do you mean?



    it works in REST API



    and local API

  • default discord avatar
    christopher.nowlan3 years ago

    Im using it with NextJS.



    But I think Im not doing it right

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.