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.

Re: Themes list using GraphQL

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 121

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 8 (8)

Ryan
Shopify Staff
499 42 121

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?

 

CafeDelMar
Shopify Partner
39 9 12

It's been 3.5 years. Has anything changed? Maybe I'm missing it but I can't find the way to retrieve theme data via GraphQL.

I currently need to detect themeID and it looks like I'd have to utilize rest API just for this. This is surprisingly odd.

➡➡   Prefetch Master   ⬅⬅ Increase your store speed with a couple of clicks



- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
ShopifyDevSup
Shopify Staff
1453 239 532

Hey @CafeDelMar

 

Currently the theme API's are still only available in REST. If it helps, we have our documentation here on integrating your apps with the online store and themes and the various ways it can be achieved: https://shopify.dev/docs/apps/online-store 

 

Cheers, 

 

- 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

leonpl
Shopify Partner
13 0 3

Rest is depreacted, u can now use GraphQL query theme and also to read in the JSON template/config data. 

Moritz-PV
Shopify Partner
14 1 12

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
}