Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilterInputs cannot be null when used in where #7956

Open
teberl opened this issue Jan 27, 2025 · 0 comments
Open

FilterInputs cannot be null when used in where #7956

teberl opened this issue Jan 27, 2025 · 0 comments

Comments

@teberl
Copy link

teberl commented Jan 27, 2025

Product

Hot Chocolate

Version

15.0.0-p.21

Link to minimal reproduction

https://github.com/teberl/HotChocolate_Playground

Steps to reproduce

  • Build and run the project
  • Open Nitro
  • Run a query containing a filter
query Products {
  products(first: 10, where:  {
     name:  {
        contains: null
     }
  }) {
    nodes {
      id
      internalId
      name
      price
      description
    }
  }
}

What is expected?

In order to use filters in queries, it should be possible to send null values in where FilterInput's.
The client should be able to write parameterized filter queries, for example:

query Products($name: String, $arrivalDateStart: Date, $arrivalDateEnd: Date) {
  products(
    first: 10
    where: { name: { contains: $name }, arrivalDate: { gte: $arrivalDateStart, lte: $arrivalDateEnd } }
  ) {
    nodes {
      id
      internalId
      name
      price
      description
    }
  }
}

A query like this cannot be written atm from a client.
This will cause a Null value not supported errror. But since variables in the cost specification are quite expensive, this is a necessary requirement to keep the cost in an adequate range.

What is actually happening?

When sending a filter containing where, all variables need to be defined.

{
  "errors": [
    {
      "message": "The provided value for filter `contains` of type StringOperationFilterInput is invalid. Null values are not supported.",
      "locations": [
        {
          "line": 4,
          "column": 19
        }
      ],
      "path": [
        "products"
      ],
      "extensions": {
        "code": "HC0026",
        "expectedType": "String!",
        "filterType": "StringOperationFilterInput"
      }
    }
  ],
  "data": {
    "products": null
  }

Relevant log output

"extensions": {
        "code": "HC0026",
        "expectedType": "DateTime!",
        "filterType": "DateTimeOperationFilterInput",
        "remotePath": [
          "experiments"
        ]
      }

Additional context

  • It seemed to work in 14.0.0-p.100, at least for the string filter i didn't realize the problem

  • Tested in 14.3.0 (our current production version) problem exists

  • Tested in 15.0.0-p.21 (current preview version) problem exists

  • Tested with several different filter inputs IdOperationFilterInputType, DateTimeOperationFilterInputType and StringOperationFilterInputType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant