Plugin example: setting the GraphQL type to use for a given PostgreSQL type
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 45/100
- Type d'issue
- Documentation
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- graphql, postgresql, typescript
- Domaine
- api, databases, documentation
Piste de recherche
Le corps de l’issue fournit un exemple de plugin TypeScript utilisant GraphQL et PostgreSQL, mais ne nomme aucun fichier du dépôt ni aucun test. Localisez la section appropriée consacrée aux exemples de plugins ou de documentation, puis vérifiez que l’exemple documenté couvre les types de type scalaire et mentionne l’exigence d’enregistrement séparé des types d’entrée/sortie pour les types composites.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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;
});
};
}
- Langage dominant
- SCSS
- Étoiles
- 27
- Forks
- 124
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de graphile/graphile.github.io
-
help wanted quick
Difficulté 2/5 1-3 heures Accessibilité débutants 38/100
graphile/graphile.github.io#401 · 1 commentaire · 1 réaction ·
-
website: Update details on homepage and sponsor pagePeut-être à nouveau libre @jemgillam l’a pris il y a 1119 jours, et aucune pull request n’est ouverte. Ouvertequick
graphile/graphile.github.io#399 · 4 commentaires · 1 personne assignée ·
-
sponsor page: New wording around Grafast needed!Peut-être à nouveau libre @jemgillam l’a pris il y a 1149 jours, et aucune pull request n’est ouverte. Ouverte
graphile/graphile.github.io#393 · 1 réaction · 1 personne assignée ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 38/100
graphile/graphile.github.io#341 · 1 réaction ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 25/100
graphile/graphile.github.io#280 · 2 commentaires · 5 réactions ·
Toutes les issues de graphile/graphile.github.io
Issues similaires
-
Bug: fenced drafts inside <think> tags break parsing or are returned instead of the answerPeut-être pris @aad1tyaaaaa l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
google/langextract#639 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Niko1221/Strata#7211 · 3 commentaires ·
Les mainteneurs répondent en général sous 5 jours
-
[Bug]: Cannot add sales line item to sales order, on an on-prem installation with basic licenseOuverteTeam: SCM
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
microsoft/BCApps#14569 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
directus/directus#28558 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours