GraphqlQueryError: Variable $productId of type ID! was provided invalid value

Hi via storefront API, I am trying to get recommended products, only every time I get this error: GraphqlQueryError: Variable $productId of type ID! was provided invalid value.

My code

obj.id="gid://shopify/Product/1234567890";

let response = await storefront.graphql(
          `#graphql
              query productRecommendations($productId: ID!) {
                productRecommendations(productId: $productId) {
                  id
                }
              }`,
          {
            productId: obj.id
          }
        );

Can you help me solve it?

Every time I try to run it it also gives me an error in the form of a Response object, but I can never access its values, do you also know how to access the values ​​to better display the error?
I use the 2024-10 release

1 Like

Hi, I tried to use only the id number but it still gives me the same error, I saw from the documentation that the entire global id is needed (https://shopify.dev/docs/api/storefront/2024-01/scalars/ID).

I tried to access with the try and catch, only that it shows me less data than before and I can’t access the object that should give me more information about the error

Getting the same. It works if I pass it a handle.