Skip to content

GraphQL ProductFilterInput Requires Field to be a String #14312

@maxbucknell

Description

@maxbucknell

Every field of the ProductFilterInput input field in Magento_CatagolGraphQl::etc/graphql.xml has the type FilterTypeInput. The problem here is that FilterTypeInput requires most of its arguments to be strings.

For example, I might want to select products that do not have a special price set. This might be some query like:

{
  products(filter: { special_price: { null: true } }) {
    total_count
  }
}

The devdocs, and basic intuition seem to suggest this is okay. However, this doesn't work because Magento_GraphQl::etc/graphql.xml requires the null field in FilterTypeInput to be a string.

Preconditions

  1. This is GraphQL, so it's in 2.3-develop, natch.

Steps to reproduce

  1. Try to submit the query written above.

Expected result

Based on the documentation, I would expect this to be a legal query.

Receive a response like this:

{
  "data": {
    "products": {
      "total_count": 0
    }
  }
}

Actual result

Response:

{
  "errors": [
    {
      "message": "Argument \"filter\" has invalid value {special_price: {null: true}}.\nIn field \"special_price\": In field \"null\": Expected type \"String\", found true.",
      "category": "graphql",
      "locations": [
        {
          "line": 2,
          "column": 20
        }
      ]
    }
  ]
}

This also applies to other fields. For example, I was unable to filter products by category ids.

Metadata

Metadata

Assignees

Labels

Component: Framework/WebapiUSE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just CatalogEvent: distributed-cdDistributed Contribution DayFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Format is validGate 1 Passed. Automatic verification of issue format passed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions