Headless commerce and custom storefronts with Shopify APIs and SDKs
Hi,
I'm trying to fetch information of a single product in Unity through Unity Buy SDK. Since I need info from the Media object, the ShopifyBuy.Client().products() is not enough and I'm using ShopifyBuy.Client().query(query, callback);
To specify the query, I've created the GraphQL root query to fetch the necessary fields for product with filter title "Test Sofa":
QueryRootQuery query = new QueryRootQuery();
query.products(p => p
.edges(pe => pe
.node(pn => pn
.description()
.handle()
.id()
.media(m => m
.edges(me => me
.node(mn => mn
.alt()
.onModel3d(ms => ms
.sources(src=> src
.format()
.url())))))
.onlineStoreUrl()
.title()))
,1,null,null,null,null,null,"title:Test Sofa",null);
(Refer attachment for snippet)
But when I pass this query, I'm getting an error from the API:
["You must provide one of first or last"]
I know this means we have to pass the 'first' or 'last' for the query to get amount of objects returned. But I'm not able to figure where to put this value in the method signature of query.products() . I passed 1 as the value for long first, but I'm still seeing the same message. I've been through the documentation and the code of QueryRootQuery.
Could anyone help me write the exact code to achieve this i.e. pass the first/last values that the API requires?
Thanks.
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023