Skip to content

Can't use input type in query #15827

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

Closed
PiotrSzlagura opened this issue Jun 5, 2018 · 3 comments
Closed

Can't use input type in query #15827

PiotrSzlagura opened this issue Jun 5, 2018 · 3 comments
Labels
Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@PiotrSzlagura
Copy link

PiotrSzlagura commented Jun 5, 2018

Preconditions

  1. Magento version: 2.3
  2. PHP: 7.1.18
  3. Server: nginx, version: 1.12.2

Steps to reproduce

  1. Create empty Magento 2.3 instance
  2. Install sample data from repo
  3. Using graphql client/plugin of your choice (tested on many of them, always with the same result) send POST request to http://[your Magento instance]/index.php/graphql
query GetProductsQuery($page: Int, $filterInput: ProductFilterInput){
  products(
    pageSize: 10
    currentPage: $page
    filter: $filterInput
    sort: {}
  ) {
    items {
    	name
    }
  }
}

with variables:

{
  "page": 1,
  "price": {
    "gt": "10"
  }
}

Expected result

  1. Query should return filtered products list, since ProductFilterInput is an input type, according to scheme

Actual result

  1. Received following error:
Variable "$filterInput" cannot be non-input type "ProductFilterInput".
Variable "$filterInput" of type "ProductFilterInput" used in position expecting type "ProductFilterInput".

I've tested this approach on clean GraphQL installation and it worked without any problem.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 5, 2018
@zetlen
Copy link

zetlen commented Jun 27, 2018

I ran into this too! The types called "Input" in our schema are not implemented as actual GraphQL input types in the current build.

Workaround: Build the filter input shape inside the query, and use only primitives as variables.

query GetProductsQuery($page: Int, $minPrice: String){
  products(
    pageSize: 10
    currentPage: $page
    filter: {
      price: {
        gt: $minPrice
      }
    }
    sort: {}
  ) {
    items {
    	name
    }
  }
}

with variables:

{
  "page": 1,
  "price": {
    "gt": "10"
  }
}

This is a real bug and not a style issue, because without an actual input type, the filter conditions are not actually configurable--they're hardcoded into the query. I'm sure that wasn't the intention.

@ghost ghost self-assigned this Aug 16, 2018
@ghost
Copy link

ghost commented Aug 16, 2018

@PiotrSzlagura, thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Aug 16, 2018
@ghost ghost removed their assignment Aug 16, 2018
@misha-kotov
Copy link

This issue is a duplicate of magento/graphql-ce#93 - we will be tracking progress over there in the GraphQL project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Webapi Use with concrete module component label E.g. "Component: Webapi" + "Catalog" Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants