print() can change a document's meaning: shorthand query after a definition without a body
I maintainer di solito rispondono entro 1 giorno
@nimbly1 ci sta già lavorando.
Dal 23/10/2026.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- graphql, javascript, typescript
- Ambito
- tooling
Direzione di ricerca
Start with the Document printer and the parse/print round-trip behavior described in the reproduction. Check how anonymous query shorthand is emitted after bodyless type, interface, input, enum, and schema definitions or extensions. Add regression coverage for the affected definition forms and verify that reparsing preserves the operation or reports the expected syntax error.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
print writes an anonymous query without variables or directives in shorthand form, { ... }. When the previous definition is a type, interface, input or enum definition or extension without a body, or a schema extension without operation types, the parser reads that { as the previous definition's body. Printing and reparsing then gives a different document, and the query is gone.
Reproduction (graphql 17.0.2; the printer code is the same on 16.x.x and next):
import { parse, print } from 'graphql';
const document = parse('type A\n\nquery { a: b }');
const printed = print(document);
// 'type A\n\n{\n a: b\n}'
parse(printed).definitions;
// one ObjectTypeDefinition `A` with a field `a: b`; the OperationDefinition is gone
The same happens after interface A, input A, enum A (with { a }), extend type A @d, and extend schema @d (with { query: b }). Where the query's selections aren't valid as the previous definition's body, the printed document is a syntax error instead.
This was found by fuzzing a Rust port of graphql-js with a print/parse round-trip property.
A possible fix: in the Document printer, keep the query keyword when the previous definition can take a body, i.e. it is an object, interface, input object or enum type definition or extension with no fields/values, or a schema extension with no operation types. Single-definition output and all other documents stay unchanged. I'm happy to open a PR with that change and tests.
- Lingua principale
- TypeScript
- Stelle
- 20.3k
- Fork
- 2.1k
- Merge medio
- 6h 51m
- PR unite (30g)
- 117
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di graphql/graphql-js
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
graphql/graphql-js#5001 ·
I maintainer di solito rispondono entro 1 giorno
-
api-testAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
graphql/graphql-js#4848 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
graphql/graphql-js#4834 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 35/100
graphql/graphql-js#4822 ·
I maintainer di solito rispondono entro 1 giorno
-
v17.1 / v18 RoadmapAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
graphql/graphql-js#4818 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di graphql/graphql-js
Issue simili
-
idea-scout idea:453
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
jeanibarz/agent-notebook#453 ·
I maintainer di solito rispondono entro 1 giorno
-
level/task
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
wazuh/wazuh-dashboard-plugins#9642 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 91/100
unicef/adt-studio#1112 ·
I maintainer di solito rispondono entro 2 giorni
-
feature request good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
TabularisDB/tabularis#1513 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100