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

GraphQL ProductFilterInput Requires Field to be a String #14312

Closed
maxbucknell opened this issue Mar 24, 2018 · 3 comments
Closed

GraphQL ProductFilterInput Requires Field to be a String #14312

maxbucknell opened this issue Mar 24, 2018 · 3 comments
Assignees
Labels
Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Event: distributed-cd Distributed Contribution Day Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@maxbucknell
Copy link
Contributor

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.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Mar 24, 2018
@maxbucknell maxbucknell self-assigned this Mar 24, 2018
maxbucknell added a commit that referenced this issue Mar 25, 2018
maxbucknell added a commit that referenced this issue Mar 25, 2018
@maxbucknell
Copy link
Contributor Author

After some research, I have found that this isn't what is causing this particular issue. While there is an issue with using the same FilterTypeInput field and requiring all fields to be a String, this particular issue is caused by /issues/14355, and I will fix that.

I believe that the FilterTypeInput issue does require further discussion, though.

@maxbucknell maxbucknell added Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Event: distributed-cd Distributed Contribution Day labels Mar 25, 2018
@misha-kotov
Copy link

Hey @maxbucknell since the root cause is described in the other ticket, can we close this issue? We can discuss FilterTypeInput in slack or offline

@magento-engcom-team
Copy link
Contributor

Hi @maxbucknell. Thank you for your report.
The issue has been fixed in #14356 by @maxbucknell in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Apr 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Event: distributed-cd Distributed Contribution Day Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

3 participants