Skip to content

fix(hydrogen): pass relative schema paths to gql check on Windows - #4367

Open
Peerapatfc wants to merge 2 commits into
Shopify:mainfrom
Peerapatfc:fix/gql-check-windows-schema-path
Open

Peerapatfc wants to merge 2 commits into
Shopify:mainfrom
Peerapatfc:fix/gql-check-windows-schema-path

Conversation

@Peerapatfc

Copy link
Copy Markdown

Closes #4359

TL;DR: hydrogen gql check fails on Windows with [Network] fetch failed because the Hydrogen schema paths are passed to gql.tada as absolute paths, and gql.tada treats a Windows drive-letter path as a URL.

Before

gql check passed join(packageRoot, "dist") (absolute) to createGraphQLPluginConfig. gql.tada runs new URL(schema) before deciding a schema is a file. On Windows new URL("C:\\x\\y.json") succeeds (protocol c:), so the schema is fetched over the network and the command fails.

After

The schema directory is passed relative to the temporary tsconfig. A relative path is not a valid URL, so gql.tada falls back to reading the file.

What this changes

  • packages/hydrogen/src/cli/gql.ts: adds an exported getSchemaDirectory() helper (takes an injectable path API) and uses it to build the schema directory.
  • packages/hydrogen/src/cli/gql.test.ts: expects relative schema paths, and adds tests that simulate Windows paths with path.win32.

Developer impact

Includes a patch changeset for @shopify/hydrogen. No new public exports or runtime contract changes.

Out of scope

  • Cross-drive Windows setups (see Risk). A possible follow-up is to copy the two schema files next to the temporary tsconfig and reference them by relative name. A file: URL is not an option: gql.tada runs new URL() first, so it would be fetched rather than read from disk.
  • src/ts-plugin/index.ts also passes an absolute SCHEMA_DIRECTORY to the same helper (editor plugin). Not changed here; possible follow-up.

Risk

  • Cross-drive case is not fixed. If the project and the Hydrogen package are on different drives (for example project on D:, package on C:), path.relative returns an absolute path and the bug remains. A unit test documents this as a known limitation.
  • Backslash relative paths (..\..\x) are not URLs, but I have not confirmed on Windows that gql.tada then reads them from disk.

How to Test

On Windows (Node 24+):

  1. Run pnpm install && pnpm build:pkgs.
  2. In a Hydrogen project with a tsconfig.json, link the built @shopify/hydrogen package.
  3. Run npx hydrogen gql check.
  4. Confirm it reports No problems found instead of [Network] fetch failed.

Verification so far: unit and integration tests pass on Linux (Node 22). Not yet verified on Windows.

gql.tada runs new URL(schema) before treating a schema as a file. On Windows
an absolute path like C:\x\y.json parses as a URL (protocol c:), so the schema
was fetched over the network and gql check failed. Pass a path relative to the
temporary tsconfig instead, and add unit tests that simulate win32 paths.
@Peerapatfc
Peerapatfc force-pushed the fix/gql-check-windows-schema-path branch from 60557bc to 475bf39 Compare November 12, 2026 06:45
@Peerapatfc

Copy link
Copy Markdown
Author

I have signed the CLA!

1 similar comment
@Peerapatfc

Copy link
Copy Markdown
Author

I have signed the CLA!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hydrogen gql check fails on Windows: absolute schema path is parsed as a URL by gql.tada

1 participant