Hi,
I've almost completed my first admin app, however I'm a little bit stuck with the admin links. I'm trying to use graphql where possible, although I have had to build a hybrid solution that also uses the REST API where mutations are not available. I've got a page that will link directly from a product page and then I was hoping to use a graphql query to get the data for that product, but I've just realised that the only parameter sent back is the legacy resource id. Is there any way we can have the graphql id sent back too? I can't see any way of looking up the data now, other than using the REST API?
Thanks,
Charlotte
Hey charbone,
I'm actually running into a similar issue and my solution was exactly the same as yours but I have a small concern with it. Shopify suggests that we don't manually build the GraphQL IDs by appending the legacy resource ID as we both have done it seems. They state that the format of that ID could change in the future and so we shouldn't rely on it being the same.
However, I can't see another way around this. My question to Shopify is, will there be an additional parameter that contains the GID so that we can ensure we're not building those manually? If not, then what would be the recommended approach?
Also interested in this topic.
In my case I have admin links on products/customers/orders but the only thing I receive in my embedded app is a legacy id like "4729xxxxx5537". How can I distinguish what type of resource is it? Or should I craft my admin links in a way that I have information about a resource type?
For example my admin link will be myapp.com/product?id=4729xxxxx5537 -> so I know this is a product and get it via GraphQL query?
I'm fairly sure that when you retrieve records through the REST API, the GraphQL record ID gets passed back to you. See https://shopify.dev/docs/admin-api/rest/reference/products/product#show-2020-07 for an example of fetching a product. The admin_graphql_api_id field is what the record ID is over in GraphQL. Of course this means that you would have to make an API request to the REST API endpoint to pull the GraphQL record ID in order to ensure you are hitting the correct thing. In the event Shopify modifies the legacy ID logic sometime in the future...
User | Count |
---|---|
13 | |
12 | |
10 | |
8 | |
7 |