GraphQL query variables not working

I’m using the slug solution from here: [cp 2] generate slug when saving collection

My (contrived) query:

query projectQuery($slug: String) {
  project: projectsModel(filter: {slug: $slug}) {
    _id
    slug
    title
  }
}

Query variables:

{
  "slug": "my-test-slug"
}

The result is always an empty projectModel. If I manually enter the slug into the query (instead of $slug) the query returns the correct result.

Why isn’t this working? Is it related to the slug solution used?

try:

query projectQuery($filter: JsonType) {
  project: projectsModel(filter: $filter) {
    _id
    slug
    title
  }
}

Query variables:

{"filter": {"slug": "my-test-slug"}}