Solved

Themes list using GraphQL

clucs123
Excursionist
18 0 3

Hello

 

I'm writing an embedded app and I need it to display a list of themes for the user. Once the user has selected a theme I then want to add some assets to that theme. I want to move away from REST to using GraphQL.

 

The endpoint for REST is...

/admin/api/2019-10/themes.json

Is this query possible using GraphQL? I can't find a queryRoot that relates to themes or assets.

 

Many thanks

 

Paul

Accepted Solution (1)

Ryan
Shopify Staff
499 42 120

This is an accepted solution.

Hi @clucs123,

 

I took a quick look as well and I don't believe themes or assets are accessible via API currently.  Is there something you are trying to accomplish that can't be done through REST so you were looking at GraphQL? Or just converting in general.

Ryan | 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 5 (5)

Ryan
Shopify Staff
499 42 120

This is an accepted solution.

Hi @clucs123,

 

I took a quick look as well and I don't believe themes or assets are accessible via API currently.  Is there something you are trying to accomplish that can't be done through REST so you were looking at GraphQL? Or just converting in general.

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

clucs123
Excursionist
18 0 3

Hi Ryan

 

I'm just trying to use graphql whenever possible and couldn't find themes or assets anywhere in the schema.

 

I using the REST API now for the themes GET so it's not a problem.

 

Thanks for taking a look.

 

Paul

neel738
Tourist
6 0 1

Hi! is there a way to access assets/themes using GraphQL?

 

 

ryantkelly
Excursionist
12 0 12

Hi -

Looks like this thread is quiet, but is just what I'm looking for.

The /themes.json endpoint from REST API returns a graphQL id:

        {
            "id": 123456789,
            "name": "Theme 4 Old",
            "created_at": "2019-08-02T11:41:13-04:00",
            "updated_at": "2020-03-23T14:54:10-04:00",
            "role": "unpublished",
            "theme_store_id": null,
            "previewable": true,
            "processing": false,
            "admin_graphql_api_id": "gid://shopify/Theme/123456789"
        }

 

I find it odd that this isn't actionable in GraphQL at all. Is this just default behavior for all REST endpoints, and preparation for the future?

 

Moritz-PV
Shopify Partner
10 0 3

Edit: Oops, wrong thread. Seems I can't delete my post. Anyway, since it may be vaguely related, I will just leave here what I wrote in case someone is looking for how to access theme section translations:

I think I finally found a way. Will be a bit more work to find the translations one needs, deciphering the ids for section content, but it seems that's where one can find them.

 

query {
  translatableResources(first: 10, resourceType: ONLINE_STORE_THEME) {
    edges {
      node {
        resourceId
        translatableContent {
          key
          value
          digest
          locale
        }
        translations(locale: "de") {
          key
          locale
          market {
            name
            id
            enabled
          }
          outdated
          updatedAt
          value
        }
      }
    }
  }
}

 

 

 



Edit 2: This will only retrieve translations for the live theme. For other themes use "translatableResourcesByIds" with the corresponding theme ids:

 

 

 

translatableResourcesByIds(first: 10, resourceIds: ["gid://shopify/OnlineStoreTheme/109876543210", "gid://shopify/OnlineStoreTheme/12345678910"]) {
  ...same fields as other query above
}