Support `custom root type names` in schema (e.g. query_root instead of Query)

Aperta
#849 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
kotlin
Ambito
tooling

Direzione di ricerca

Inizia individuando la configurazione di codegen e il punto di ingresso dell’elaborazione dello schema che rileva i tipi root di query, mutation e subscription. Riproduci il problema con lo schema in stile Hasura mostrato qui; il lavoro è completato quando nomi root personalizzati e configurabili generano codice client senza dover riscrivere manualmente lo schema.

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

Descrizione

Hi DGS team 👋

We’re currently using DGS Codegen to generate Java client code from a GraphQL schema that is generated by Hasura.

Hasura generates a valid GraphQL schema with custom root type names, such as query_root, mutation_root, and subscription_root, instead of the usual Query, Mutation, and Subscription.

Example schema:

schema {
  query: query_root
  mutation: mutation_root
  subscription: subscription_root
}

type query_root {
  # some fields here
}

type mutation_root {
  # some fields here
}

type subscription_root {
  # some fields here
}

While this is perfectly valid according to the GraphQL spec (see GraphQL spec 3.2), it seems that DGS Codegen relies on the root types being named Query, Mutation, and Subscription, and does not generate code for these custom root types.

Our current workaround

As a workaround, we manually rewrite the schema before passing it to DGS Codegen:

schema {
  query: Query
  mutation: Mutation
  subscription: Subscription
}

# then copy contents from query_root to Query, etc.

This allows client code generation to work properly, but it’s a manual.

Feature request

Would it be possible for DGS Codegen to allow users to configure the names of the root types (query, mutation, subscription) via codegen config ?

Motivation

This would improve compatibility with Hasura and any other GraphQL server that uses valid non-standard root type names, without requiring manual schema rewriting.

Sources

https://github.com/deweyjose/graphqlcodegen/issues/245#issuecomment-2944055960

Lingua principale
Kotlin
Stelle
220
Fork
123
Merge medio
1g 6h
PR unite (30g)
23

Preparare l'ambiente

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 Netflix/dgs-codegen

Tutte le issue di Netflix/dgs-codegen

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.