PSA on GraphQL

Shopify Expert
4219 31 422

I did not catch this right away, but here we go.

 

In a GID the format is gid://shopify/resource/id

First weird but true thing to note. Capitalization on the word shopify. It is LOWERCASE. Why? Who knows, who cares. Just don't mess that up.

On to resources. Note that a resource in my terms is something like a Product or a Collection. Why did I capitalize that. No reason. Maybe I like the shift key. Maybe I am just a stickler for punishment.

 

DO NOT screw with the case of a resource. If you do, this benign little thing in a complex query you will cause an INTERNAL SERVER ERROR at Shopify.

gid://shopify/collection/123456789       =====> Nuke the server, cause problems. Now you have hole in jeans where no hole should be

gid://shopify/Collection/123456789      => Get back data. Normal world. No holy jeans.

Whoever says this is fine and normal with a straightface, you have lived a sheltered life, try getting out and living off the land for a few days.

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
Shopify Partner
12 0 3

IIRC, Shopify doesn't really encourage you to construct these GIDs by yourself as their format could be subject to change at some point in the future. It's probably better to defer to the ID you're receiving in the payload, and if you're mixing REST And GraphQL calls, defer to the `admin_graphql_id` in the REST API response.

0 Likes
Highlighted
Shopify Expert
4219 31 422

Oh ya. In theory I agree 100%. But, as you well know, we don't always get nice shiney GIDs when working the API world, so in this case, I had to deal manual mode. Nonetheless, my comment stands, if you mess up case, you get blotto-the-server.

I will re-trace my steps though, and if I can refactor out the manual gid I will for sure. As you say, you never know when someone drops a hammer in the mix and all of a sudden things change.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes