`gql check` and the TS plugin still fail on Windows when schema paths are absolute

Aperta
#4,371 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@JooaoGui ci sta già lavorando.

Dal 23/11/2026.

  • #4421 di @JooaoGui — aperta

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript, vscode
Ambito
devtools, testing

Direzione di ricerca

Start with src/ts-plugin/index.ts, the schema loading helper in @gql.tada/internal 1.0.9, and graphqlsp 1.15.4; then review #4359 and #4367. Reproduce absolute-path loading on Windows, including a project and package on different drives, and verify how backslash relative paths are handled. Done means both gql check and the editor plugin load schemas from disk on Windows, with VS Code testing and no regressions on other platforms.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Follow-up to #4359 and the draft fix in #4367.

Status: neither case below has been reproduced on Windows yet. Both come from reading the code in @gql.tada/internal 1.0.9 and @0no-co/graphqlsp 1.15.4, plus Node URL behavior checks that are platform independent.

Background

gql.tada's getURLConfig runs new URL(origin) first. If that parses, the schema is loaded with loadFromURL (a network fetch). Only if it throws is the string treated as a file path and read via resolve(rootPath, origin).

On Windows, new URL("C:\\x\\y.json") parses (protocol c:), so an absolute drive-letter schema path is fetched instead of read from disk, which is the [Network] fetch failed in #4359. A file: URL is not a workaround: it parses as a URL too and goes to fetch.

#4367 fixes hydrogen gql check by passing the schema directory relative to the temporary tsconfig. Two cases remain.

1. Project and Hydrogen package on different drives

path.relative cannot produce a relative path across drives, so it returns the absolute path (for example path.win32.relative('D:\\proj\\.t', 'C:\\pkg\\dist') returns C:\pkg\dist). That parses as a URL, so hydrogen gql check still fails for this layout. A unit test in #4367 documents this as a known limitation.

Possible fix: copy the two schema files (about 1.4 MB and 1.7 MB) next to the temporary tsconfig and reference them by relative name, cleaned up with the existing temporary-file cleanup.

2. Editor TypeScript plugin

src/ts-plugin/index.ts passes an absolute SCHEMA_DIRECTORY = resolve(__dirname, "..") to the same helper, loaded through graphqlsp, which applies the same URL check. It very likely fails the same way on Windows, probably only logging Failed to load schema in the editor.

Things to be careful about:

  • graphqlsp computes rootPath asynchronously from resolveTypeScriptRootDir(project.getProjectName()), so a relative path needs the right base directory. A wrong base would break every OS.
  • The change should apply only when the absolute path would parse as a URL, to leave POSIX behavior untouched.
  • It needs testing in VS Code on Windows.

Needed

  • Reproduction of both cases on Windows (including a cross-drive setup).
  • Confirmation from #4359 on whether backslash relative paths are read from disk by gql.tada, which affects the approach for both.
Lingua principale
TypeScript
Stelle
2.2k
Fork
466
Merge medio
3g 18h
PR unite (30g)
59

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Shopify/hydrogen

Tutte le issue di Shopify/hydrogen

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.