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.

Field admin_graphql_api_id not in the json object via webhook...?

Solved

Field admin_graphql_api_id not in the json object via webhook...?

samwise
Shopify Partner
31 0 6

Per docs - https://help.shopify.com/en/api/reference/products/product#show

 

that field should be part of json 

    "admin_graphql_api_id": "gid://shopify/Product/632910392",

I do not see it is coming via webhook(product/update). Is this expected? 

 

I thought to use it against GraphQl endpoint. Is this recommended way?   

 

Based on this(https://help.shopify.com/en/api/graphql-admin-api/migrating-from-rest) it seems it is not.

GraphQL IDs are opaque
GraphQL ID generation is implementation dependent, and as 
such does not follow any convention other than being a URI.
There is no guarantee that GraphQL IDs will follow a similar
"structure" (gid -> shopify -> resource -> rest_id) to the previous example, and
so you shouldn't IDs programatically.

Otherwise, it seems I need to make a call to pull it when I receive webhook.   Any thoughts on this?

 

Accepted Solutions (2)

Josh
Shopify Staff
1134 84 235

This is an accepted solution.

Hey there, 

 

This seems like it may have just been an oversight - I'll report this internally and see what we can do to get it fixed. Thanks for pointing it out! 

Josh | 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

Josh
Shopify Staff
1134 84 235

This is an accepted solution.

Certainly! 

 

So - while this should be ok for the time being, ultimately there's no guarantee that the formatting of GraphQL IDs will always remain the same. That's basically just us reserving the right to change the URL structure globally or possibly even use different URL structures in different places. 

 

Not an issue right now though, that's just a warning that it is not good practice because it's entirely possible for it all to change in the future. Given your current situation though and the fact there's likely a solution coming, what you're doing should be ok provided that it's only used temporarily.

Josh | 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 10 (10)

Josh
Shopify Staff
1134 84 235

This is an accepted solution.

Hey there, 

 

This seems like it may have just been an oversight - I'll report this internally and see what we can do to get it fixed. Thanks for pointing it out! 

Josh | 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

samwise
Shopify Partner
31 0 6

Thanks much @Josh!  just to understand is this something will be enabled on next release - 2019-07?   if so I will switch my meta to that release. I would like to start using it. 

 

Josh
Shopify Staff
1134 84 235

It's a bit too early to promise anything yet to be honest, still waiting to hear back. I'll let you know once I have more info to share!

Josh | 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

samwise
Shopify Partner
31 0 6

Thanks so much @Josh ! 

Josh
Shopify Staff
1134 84 235

Hey again, 

 

So a bit more context here - we actually did have this field in webhooks before, and it ended up breaking a bunch of API clients that were parsing them in some very specific ways.

 

We do want to bring it back though, but this does likely mean that if we were to do so it would have to be in the next API version. There hasn't been a final decision quite yet since this conversation was just kicked off yesterday, but fingers crossed we'll have this out for you in v2019-07. 

Josh | 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

samwise
Shopify Partner
31 0 6

@Josh  ehhh .... killer!  🙂 

 

I did some workaround for now.  I guess it should be ok. 

 

    decorProduct := "gid://shopify/Product/" + strconv.FormatInt(product.ID, 10)

 

The only concern I have on this wording since I am decorating URI now.

 

There is no guarantee that GraphQL IDs will follow a similar "structure" 
(gid -> shopify -> resource -> rest_id)
to the previous example, and so you shouldn't IDs programatically

Ref: https://help.shopify.com/en/api/graphql-admin-api/migrating-from-rest

 

Can you comment on this? 

 

Thanks much!

 

 

 

Josh
Shopify Staff
1134 84 235

This is an accepted solution.

Certainly! 

 

So - while this should be ok for the time being, ultimately there's no guarantee that the formatting of GraphQL IDs will always remain the same. That's basically just us reserving the right to change the URL structure globally or possibly even use different URL structures in different places. 

 

Not an issue right now though, that's just a warning that it is not good practice because it's entirely possible for it all to change in the future. Given your current situation though and the fact there's likely a solution coming, what you're doing should be ok provided that it's only used temporarily.

Josh | 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

samwise
Shopify Partner
31 0 6

Ok. 

 

I added additional logic around it and will be changing to new version 2019-07.  I decided to unmarshal two IDs - id and admin_graphql_api_id.  if admin_graphql_api_id is an empty fallback to decorated otherwise I will use it.  

 

Anyway, I am still finalizing on the app so I feel I will be ok.  Thanks so much @Josh 

ClementG
Shopify Partner
660 0 130

We also would love admin_graphql_api_id in webhooks.

I'm not sure why this broke clients, it's used an extra field...

Anyway, please include it in 2019-07!

HSL
Shopify Partner
40 0 4

Any updates on if this will be available in v2019-07?

And very curious, what does the data Shopify sends to webhook endpoints have to do with the API versions?