🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

GraphQL Query: Filtering not Working Properly

2 replies
Last updated: Feb 1, 2022
Hello looking to get some insight into this query I am building (it is with graphQL)

{
    allSeriesType(
      where: {
        _: { is_draft: false }
        isPublished: { eq: true }
        title:{matches:"master the basics"}
      }
      sort: [{ publishDate: DESC }]
    ) {
    title
    }
  }
It is returning:


{
  "data": {
    "allSeriesType": [
      {
        "title": "Learn the Routine: Dance Choreography"
      },
      {
        "title": "Master the Basics: HIIT"
      },
      {
        "title": "Master the Basics: Seated Dance Cardio"
      },
      {
        "title": "Master the Basics: Yoga"
      },
      {
        "title": "Master the Basics: Seated Strength Training "
      },
      {
        "title": "Master the Basics: Dance Cardio"
      },
      {
        "title": "Master the Basics: Strength Training"
      },
      {
        "title": "Master the Basics: Barre"
      },
      {
        "title": "Master the Basics: Cardio Boxing"
      },
      {
        "title": "The Gratitude Challenge: Yoga and Meditation"
      },
      {
        "title": "Master the Basics: Seated Yoga"
      }
    ]
  }
}
I am wondering why it is returning
The Gratitude Challenge: Yoga and Meditation
and
Learn the Routine: Dance Choreography
Feb 1, 2022, 4:17 PM
those dont appear to be part of the filter type
Feb 1, 2022, 4:42 PM
I see what the problem can be its because matches looks for words containing. Changed it to
master basics
and it worked
Feb 1, 2022, 4:46 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?