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

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.
    – Pramod
    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. 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
    – Pramod
    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
        }
    }
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.