Plugin example: setting the GraphQL type to use for a given PostgreSQL type
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- graphql, postgresql, typescript
- Ambito
- api, databases, documentation
Direzione di ricerca
Il corpo dell’issue fornisce un esempio di plugin TypeScript che usa GraphQL e PostgreSQL, ma non indica alcun file del repository né alcun test. Individua l’area appropriata degli esempi di plugin o della documentazione, quindi verifica che l’esempio documentato copra i tipi simili agli scalari e segnali il requisito di registrazione separata per input/output per i tipi compositi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Thanks to @Gomes on Discord. This only works for scalar-like types, for composite types you'll need to register separate input and output types (i.e. in addition to calling pgRegisterGqlTypeByTypeId you also need to call pgRegisterGqlInputTypeByTypeId)
import type { GraphQLType } from "graphql";
import type { Plugin } from "graphile-build";
import type { PgType } from "graphile-build-pg";
interface PgDomainToGqlTypePluginArgs {
/** PostgreSQL type identifier, e.g. "my_schema.my_type" */
typeIdentifier: string;
/** What GraphQL type should we use for this PG type */
gqlType: GraphQLType | ((build: Build) => GraphQLType);
}
/**
* Sets the GraphQL type `gqlType` to be used for the PostgreSQL type identified
* by `typeIdentifier`
*/
export function makePgDomainToGqlTypePlugin({
typeIdentifier,
gqlType,
}: PgDomainToGqlTypePluginArgs): Plugin {
return (builder) => {
builder.hook("build", (build) => {
const { namespaceName, entityName: typeName } = build.pgParseIdentifier(
typeIdentifier
);
const pgType = build.pgIntrospectionResultsByKind.type.find(
(type: PgType) =>
type.namespaceName === namespaceName && type.name === typeName
);
if (!pgType) {
throw new Error(`Failed to find the type '${typeIdentifier}'`);
}
build.pgRegisterGqlTypeByTypeId(pgType.id, () =>
typeof gqlType === "function" ? gqlType(build) : gqlType
);
return build;
});
};
}
- Lingua principale
- SCSS
- Stelle
- 27
- Fork
- 124
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna 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 graphile/graphile.github.io
-
help wanted quick
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
graphile/graphile.github.io#401 · 1 commento · 1 reazione ·
-
website: Update details on homepage and sponsor pageForse di nuovo libera @jemgillam l’ha presa 1119 giorni fa e non c’è nessuna pull request aperta. Apertaquick
graphile/graphile.github.io#399 · 4 commenti · 1 assegnatario ·
-
sponsor page: New wording around Grafast needed!Forse di nuovo libera @jemgillam l’ha presa 1149 giorni fa e non c’è nessuna pull request aperta. Aperta
graphile/graphile.github.io#393 · 1 reazione · 1 assegnatario ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
graphile/graphile.github.io#341 · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
graphile/graphile.github.io#280 · 2 commenti · 5 reazioni ·
Tutte le issue di graphile/graphile.github.io
Issue simili
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
dsx-ai-factory/health-validation#368 ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
Tripstack-Corp/spyc#1352 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
vllm-project/vllm#70030 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
help wanted small extra
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno