Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

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.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.