productVariant query with variant id "Required parameter missing or invalid"

Topic summary

A developer encountered a “Required parameter missing or invalid” error when executing a Shopify productVariant GraphQL query in PHP, despite the same query working successfully in Postman.

Initial Problem:

  • The query requested product variant data including price, SKU, and component information
  • Same cURL implementation worked for other queries/mutations in the application
  • Authentication and headers (content-type) were properly configured

Resolution:
The issue was resolved independently—it was a formatting error in the GraphQL query syntax. The query was missing the query keyword before the operation name, which caused the cryptic error message.

Key Takeaway:
The developer noted that more detailed error messages would have helped identify this syntax issue faster.

Summarized with AI on October 24. AI used: claude-sonnet-4-5-20250929.

Hello,

I was able to successfully run this in Postman, but in PHP, it is claiming I am missing a required parameter. Only the id is required, so what gives??

query productVariant {
    productVariant(id: "gid://shopify/ProductVariant/51370387439897") {
        id
        price
        sku
        productVariantComponents(first: 10) {
            nodes {
                id
                quantity
                productVariant {
                    displayName
                    id
                    price
                    sku
                    storefrontId
                    taxable
                }
            }
        }
    }
}

I have also tried using nodes which everybody else seems to have success with, and I get the same response! it also works fine in Postman but not in my php code.

The same cURL code that I am running here is running elsewhere in my app, with success with many queries and mutations, so I was surprised to run into this issue. I am definitely setting content-type and all that.

Any thoughts? thank you!!

@jillianctg can you provide a screenshot of the stack trace from your PHP app claiming you’re missing a required parameter?

If you are able to run the query identically in Postman, but it’s failing out in your app I wonder if your API auth token isn’t being set properly when you call Shopify from the PHP side.

Thanks for your response. Let me know if this isn’t what you are asking for.

You know what, nevermind. I just figured it out. I just wish the error messages were a little more thorough, I was just missing a “query” before the titled query and it didn’t like that formatting mistake.