Skip to content

Error in variable coercion when using custom filter in query #7024

@Mephistofeles

Description

@Mephistofeles

Product

Hot Chocolate

Version

13.9.0

Link to minimal reproduction

https://github.com/Mephistofeles/HotChocolateReproduction

Steps to reproduce

I've included minimal reproduction.
When I run query like:

query {
  machines(where: { locks: { any: true } }) {
    id
  }
}

It runs just fine, but when I create a variable for where, like:

query ($filter: MachineFilterInput) {
  machines(where: $filter) {
    id
  }
}

and use it with variables:

{
  "filter": {
    "locks": {
      "any": true
    }
  }
}

I'm getting error HC0016: Variable filter got an invalid value.
which when I debug probably comes from trying to convert "locks" to IEnumerable in HotChocolate.Utilities.DictionaryToObjectConverter.VisitObject (in call to Activator.CreateInstance(context.ClrType)) which failes, because of course IEnumerable is an interface and results in "System.MissingMethodException: 'Cannot create an instance of an interface.'"

What is expected?

Query should run the same whether I use variables or not

What is actually happening?

Query fails when I use variable for a filter input

Relevant log output

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DataIssue is related to filtering, sorting, pagination or projections🌶️ hot chocolate

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions