1

I'm querying the graphql endpoint of a magento test installation, and am constructing and sending an oauth 1.0 authorization header via an integration setup.

When I query the products via a simple graphql query like so:

query Products {
 products(
 filter: { price: { from: "0" } }
 pageSize: 20
 currentPage: 1
 sort: { name: DESC }
 ) {
 items {
 sku
 }
 }
}

I get no data as a result -

{
 "data": {
 "products": {
 "items": []
 }
 }
}

Could it be an issue with the authorization header? I've tested the header via the REST routes and it works ok there.

Thanks

asked Oct 5, 2023 at 15:09
3
  • just check in admin if filter is enabled for price attribute, also querying does not require any authorization in graphql, also i hope you already have checked with reindexing. Commented Oct 5, 2023 at 16:08
  • Ah that's interesting Pramod, thank you. I'm not at my machine rn but they all sound like things that could work. Glad the Auth is not the issue in this case so I can concentrate on that. I will need Auth for mutations in future so work is not lost there. Commented Oct 5, 2023 at 17:29
  • auth will be required in case of getting or updadting customer data such as order,address requires (requires customer token) wheres as loading all the orders irrespective of user requires integration token Commented Oct 7, 2023 at 5:30

1 Answer 1

1

You don't need any auth info for GQL.

You are missing to filter for price. Below query should work:

query Products {
 products(
 filter: { price: { from: 0, to: 500 } }
 pageSize: 20
 currentPage: 1
 sort: { name: DESC }
 ) {
 items {
 sku
 }
 }
}
answered Oct 6, 2023 at 5:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.