Skip to content

[4.x]: Pass search options via GraphQL #16970

Closed
@janhenckens

Description

@janhenckens

What happened?

Description

I'm trying to query a GraphQL endpoint on a site running Craft 4.13.7 and I'd like to override the defaultSearchTermOptions in my query.

In Twig we can do this:

{% set entries = craft.entries()
  .section('mySection')
  .search({
    query: 'salty dog',
    subRight: false,
  })
  .all() %}

When I try to pass a similar query via GraphQL

search: [{query: "salty dog"}, {subRight: false}]

That returns the following error:

{
  "errors": [
    {
      "message": "Field \"entries\" argument \"search\" requires type String, found [{query: \"salty dog\"}, {subRight: false}].",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 35,
          "column": 13
        }
      ]
    }
  ]
}

Thanks for taking a look!

Craft CMS version

4.13.7

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions