Skip to content

GraphQL Codegen fails: translatableResource not found on QueryRoot #2958

@Alopwer

Description

@Alopwer

GraphQL Codegen Validation Error for translatableResource

Issue summary

Before opening this issue, I have:

  • Upgraded to the latest version of the relevant packages
    • @shopify/api-codegen-preset: ^1.2.1
    • @shopify/hydrogen-codegen: ^0.3.3
    • Node version: v24.9.0 (npm v11.6.0)
    • Operating system: macOS
  • Set { logger: { level: LogSeverity.Debug } } in my configuration, when applicable
  • Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • Looked for similar issues in this repository
  • Checked that this isn't an issue with a Shopify API

    The query itself works in the Admin API, so this appears to be a codegen/schema issue.

Short description

The GraphQL query translatableResource is valid in the Shopify Admin API, but running @shopify/hydrogen-codegen or @shopify/api-codegen-preset fails with a validation error indicating the field does not exist on QueryRoot.

Expected behavior

The codegen should successfully validate the query and generate the corresponding TypeScript types, since translatableResource is a valid Admin API field.

Actual behavior

Running codegen produces:

Image

Steps to reproduce the problem

  1. Create a file app/admin/queries.ts with the following query:
export const COLLECTION_TRANSLATION_BY_LOCALE_AND_MARKET = `#graphql
  query CollectionHandleTranslationsByLocaleAndMarket(
    $collectionId: ID!
    $locale: String!
    $marketId: ID
  ) {
    translatableResource(resourceId: $collectionId) {
      resourceId
      translations(locale: $locale, marketId: $marketId) {
        key
        locale
        value
      }
    }
  }
` as const;
  1. Run @shopify/hydrogen-codegen (or @shopify/api-codegen-preset) on this file.
  2. Observe the validation error above.

Configuration

import type {CodegenConfig} from '@graphql-codegen/cli';
import {pluckConfig, preset, getSchema} from '@shopify/hydrogen-codegen';
import {ApiType, shopifyApiProject} from '@shopify/api-codegen-preset';

export default {
  overwrite: true,
  pluckConfig,
  generates: {
    'storefrontapi.generated.d.ts': {
      preset,
      schema: getSchema('storefront'),
      documents: ['./app/storefront/**/*.{ts,tsx,js,jsx}'],
    },
    'admin.generated.d.ts': shopifyApiProject({
      apiType: ApiType.Admin,
      apiVersion: '2025-10',
      documents: ['./app/admin/**/*.{ts,tsx,js,jsx}'],
    }),
  },
} as CodegenConfig;

Debug logs

[Codegen] GraphQL Document Validation failed with 1 errors;
Error 0: Cannot query field "translatableResource" on type "QueryRoot".
at app/admin/queries.ts:7:5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions