themeFilesUpsert Mutation

Hello shopify team.

Im trying to run themeFilesUpsert Mutation to create 6 page templates but include the relevant embeded app block. For context Im creating a copy of the admins main theme and integrating all of my shopify app features to the copied theme including attempting to inject embedded app blocks when creating template pages in my Theme Files Upsert Mutation. This is so the admin doesnt have to add any embedded app blocks manually and rather injected when creating a duplicated copied theme. Here is a test case for testing in graphQL:

Mutation:

mutation themeFilesUpsert($files: [OnlineStoreThemeFilesUpsertFileInput!]!, $themeId: ID!) {
  themeFilesUpsert(files: $files, themeId: $themeId) {
    upsertedThemeFiles {
      filename
    }
    userErrors {
      field
      message
    }
  }
}

Input:

{
  "themeId": "gid://shopify/OnlineStoreTheme/176575381784",
  "files": [
    {
      "filename": "templates/page.inx-account-dashboard.json",
      "body": {
        "type": "TEXT",
        "value": "{\n  \"sections\": {\n    \"main\": {\n      \"type\": \"main-page\",\n      \"blocks\": {\n        \"inx-account-dashboard\": {\n          \"type\": \"shopify://apps/inxsql-webservice-development/blocks/inx-account-dashboard/fef96608-1583-4025-9bd9-c104950eed41\",\n          \"settings\": {}\n        }\n      },\n      \"block_order\": [\"inx-account-dashboard\"],\n      \"settings\": {\n        \"padding_top\": 28,\n        \"padding_bottom\": 28\n      }\n    }\n  },\n  \"order\": [\"main\"]\n}"
      }
    }
  ]
}

Response:

{
  "data": {
    "themeFilesUpsert": {
      "upsertedThemeFiles": [],
      "userErrors": [
        {
          "field": [
            "files"
          ],
          "message": "App blocks are not accepted in this context."
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1990,
        "restoreRate": 100
      }
    }
  }
}

Can you inject app blocks into themefilesupsert that come from my theme extensions?

Hey shopify team. I found a solution you can close this case. Thank you.

1 Like

Thanks @Jordan_Khalil !

Care to share your solution?