Re: Returning translated blog articles?

Solved

Returning translated blog articles?

IgorPietrzak
Shopify Partner
5 0 0

Hi,

I'm creating a custom connector that will be sending store content for translation and putting translated content back to the store. All is working fine, but I've discovered that I can collect content of for example blogs for translation, but there's no handle to return it to the store?

For example this handles product all fine:

 

curl -X POST \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: [access token]" \
-d '{
  "query": "{ translatableResources(first: 1, resourceType: PRODUCT) { edges { node { resourceId translatableContent { key value digest locale } } } } }"
}' \
{"data":{"translatableResources":{"edges":[{"node":{"resourceId":"gid://shopify/Product/8320359334194","translatableContent":[{"key":"title","value":"Minion Mug","digest":"a922dda7b9982285124abdf38c7f292f08396f7851adfa3bce1f4068d8cfda76","locale":"en"},{"key":"body_html","value":"A funny looking minion mug","digest":"b128f2eb6a0190d27901727946ec3a4c49eddfd632a36aaed2777302b60a12ff","locale":"en"},{"key":"handle","value":"minion-mug","digest":"c3aabbdc69e27e07cfe3c55faec0a25166abda2a498618056dcf39f09de7070f","locale":"en"}]}}]}},"extensions":{"cost":{"requestedQueryCost":4,"actualQueryCost":4,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":996,"restoreRate":50.0}}}}%
 
 
But when I'm trying to return a blog, it returns error:
curl -X POST \
-H "Content-Type: application/json" \
-H "X-Shopify-Access-Token: [access token]" \
-d '{
  "query": "{ translatableResources(first: 1, resourceType: BLOG) { edges { node { resourceId translatableContent { key value digest locale } } } } }"
}' \
{"errors":[{"message":"Argument 'resourceType' on Field 'translatableResources' has an invalid value (BLOG). Expected type 'TranslatableResourceType!'.","locations":[{"line":1,"column":3}],"path":["query","translatableResources","resourceType"],"extensions":{"code":"argumentLiteralsIncompatible","typeName":"Field","argumentName":"resourceType"}}]}%
 
Is there any way to POST translated blogs or pages? I've looked at documentation and I couldn't find anything, so it looks like it's not possible at all?
 
Thanks in advance!
Accepted Solution (1)

lizk
Shopify Staff
246 58 78

This is an accepted solution.

Hi there 👋

I believe the resource type you should be using is ONLINE_STORE_BLOG or ONLINE_STORE_ARTICLE. 

So your GraphQL query will look something like this!

query {
  translatableResources(first: 10, resourceType: ONLINE_STORE_BLOG) {
    nodes {
      translatableContent{
        digest
        key
        value
        locale
      }
    }
  }
}





To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 3 (3)

lizk
Shopify Staff
246 58 78

This is an accepted solution.

Hi there 👋

I believe the resource type you should be using is ONLINE_STORE_BLOG or ONLINE_STORE_ARTICLE. 

So your GraphQL query will look something like this!

query {
  translatableResources(first: 10, resourceType: ONLINE_STORE_BLOG) {
    nodes {
      translatableContent{
        digest
        key
        value
        locale
      }
    }
  }
}





To learn more visit the Shopify Help Center or the Community Blog.

IgorPietrzak
Shopify Partner
5 0 0

Thanks a lot! I'll check if that works! Hope it does:)

 

IgorPietrzak
Shopify Partner
5 0 0

It works perfectly! Thank you very much for your help! Much appreciated!