Search code examples
graphqlnuxt.jsapollostrapi

Why is my graphQL query returning results without `where` filters?


I am working on a webapp with a nuxt/vuetify/apollo frontend. The backend is a strapi (v3.0.0-beta.18) server with a graphQL endpoint and a mongoDB database (v4.2.2)

It could be a newbie question since it's my first graphql project. I have a query for a collection called tags. It looks as follows:

query Tags($search: String, $selected: [ID], $limit: Int) {
  tags: tags(
    limit: $limit
    sort: "score:desc"
    where: { name_contains: $search }
  ) {
    id
    name
    description
    type
  }
  selected: tags(where: { id_in: $selected }) {
    id
    name
    description
    type
  }
}

That query is returning every result that should be filtered by the where object, while the sort and limit filters work. The behavior is the same in my frontend app and on the graphQL playground. Am I missing something?

Note that strapi Shadow CRUD feature is enabled.


Solution

  • It turns out that I missed one of the breaking changes when upgrading strapi to the latest version. The mongose connector changed its name: https://strapi.io/documentation/3.0.0-beta.x/migration-guide/migration-guide-beta.17-to-beta.18.html