Re: GraphQL for TranslatableResources

GraphQL for TranslatableResources

miwelo
Tourist
10 0 7

Hi,

 

I'm building a basic translation app for myself using ChatGPT.

 

I'm currently using GraphQL to fetch product translations doing some basic testing but I'm too new with GraphQL and I have a quesiton: How can I fetch the LAST 10 products created instead of the first 10? Also is there a way to add a filter to fetch only the translations that are outdated?

 

Thank you so much in advance

 

query MyQuery {
translatableResources(first: 10, reverse: yes, resourceType: PRODUCT) {
edges {
node {
resourceId
translatableContent {
digest
key
locale
value
}
}
}
nodes {
resourceId
}
}
}

Replies 2 (2)

ShopifyDevSup
Shopify Staff
1453 238 511

Hey @miwelo , that's a great question. 

Specifically for translatableResources, using reverse:true will reverse the order of the underlying list. 

ChatGPT can be a really great tool to help you build your graphQL queries, but just a fair warning that it does often make up queries that don't work or don't exist. Pro-tip, Copy and pasting the relevant documentation before asking it to build a query can be helpful to give it more specific context and get more accurate answers 🙂 

To help get up to speed on GraphQL as well, we have a really great workshop here that walks through it. This can give you the fundamentals so you can more easily spot when chatGPT is making things up, and to help better navigate our developer documents

Hope that helps! 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Liam
Community Manager
3108 341 879

Hi Miwelo,

 

Great to hear you're creating a new app with ChatGPT! Your query is on the right track to fetch the last 10 products with `translatableResources`, but the `reverse` argument only accepts a boolean so that should be set to `true` rather than `yes`. 

 

Try that and it should work then!

 

 

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog