What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: How to create the cartTransform object without using GraphiQl app?

Solved

How to create the cartTransform object without using GraphiQl app?

Itachi_Uchiha
Shopify Partner
26 0 1

After implementing and deploying the Cart Transform function extension to the store, the next step is to create a cartTransform object to activate the function. To do that if try to run the cartTransformCreate mutation using the access_token that I obtained by creating an app from "settings > Apps and sales channels > Develop Apps > API credentials" section I get "function not found" error.  


While the documentation always refers to using the GraphiQl app for every function activation(Ex: 1, 2), there is a need to clarify which access token to use and how to obtain it when activating the function directly from the code.

So, my question is when activating it from my code which access token to use and how do I get that? 

Really stuck here and any help will be greatly appreciated.

Thanks! 

Accepted Solution (1)

Nick_Wesselman
Shopify Staff
171 43 73

This is an accepted solution.

Hi @Itachi_Uchiha. You are correct that the API credentials from your shop won't work -- functions can only be used by access tokens from the same app that contains them. You would need to make the API request from an embedded app, such as a Remix app. The Remix app template documentation has an example of making a GraphQL call to the Admin API:

https://shopify.dev/docs/api/shopify-app-remix/v2/apis/admin-api#example-graphql

 

-Nick

Nick Wesselman | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 2 (2)

Nick_Wesselman
Shopify Staff
171 43 73

This is an accepted solution.

Hi @Itachi_Uchiha. You are correct that the API credentials from your shop won't work -- functions can only be used by access tokens from the same app that contains them. You would need to make the API request from an embedded app, such as a Remix app. The Remix app template documentation has an example of making a GraphQL call to the Admin API:

https://shopify.dev/docs/api/shopify-app-remix/v2/apis/admin-api#example-graphql

 

-Nick

Nick Wesselman | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Itachi_Uchiha
Shopify Partner
26 0 1

Thanks @Nick_Wesselman. Specially for the link. I wouldn't have found it easily.