Recipe: translate range types to/from Postgres' format instead of the object version
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 38/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- graphql, postgresql, typescript
調査の方向性
対象となるドキュメントファイルは指定されていません。まず、graphile.github.io リポジトリにある既存のレシピドキュメントを見つけ、次に、提供されている TranslateRangesPlugin の例と、その builder hook および pg2GqlMapper エントリポイントを資料として使用してください。範囲の変換動作を含むレシピが追加され、サンプルコードが明確に説明されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Sometimes the old way is more convenient :)
import { GraphQLScalarType } from "graphql"
import type { SchemaBuilder, Build } from "graphile-build"
import type { PgType } from "graphile-build-pg"
/**
* This plugin switches the expression of range types back to Postgres' native
* `[lower,upper)` formats instead of Postgraphile's more verbose nested-object
* `{start: {value, inclusive}, end: {...}` version.
*/
export default function TranslateRangesPlugin(builder: SchemaBuilder) {
builder.hook("build", (build: Build) => {
const {
pgIntrospectionResultsByKind,
pgRegisterGqlInputTypeByTypeId,
pgRegisterGqlTypeByTypeId,
pg2GqlMapper,
pgSql: sql,
} = build
// find our target type oid. If you want to change the behavior for a
// built-in range type, you can use one of the following default oids:
//
// 3904 int4range
// 3906 numrange
// 3908 tsrange
// 3910 tstzrange
// 3912 daterange
// 3926 int8range
const myRange = pgIntrospectionResultsByKind.type.find(
(t: PgType) => t.namespaceName === "my_schema" && t.name === "my_range"
)
if (!myRange) {
return build // something went horribly wrong, abort
}
// declare a new kind of scalar
const MyRangeType = new GraphQLScalarType({
name: "MyRange",
description: "An int8range dedicated to a more specific purpose",
serialize: (a: string) => a,
parseValue: (a: string) => a,
})
// register input and output types for the oid
pgRegisterGqlInputTypeByTypeId(myRange.id, () => MyRangeType)
pgRegisterGqlTypeByTypeId(myRange.id, () => MyRangeType)
// define mappings to and from
pg2GqlMapper[myRange.id] = {
// SQL -> GQL
map: (output: string) => output,
// GQL -> SQL; substitute your target range type for `int8range` as necessary
unmap: (input: string) => sql.fragment`${sql.value(input)}::int8range`,
}
return build // pass the build object back for the next stage
})
}
- 主要言語
- SCSS
- スター
- 27
- フォーク
- 124
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
graphile/graphile.github.io のほかの issue
-
help wanted quick
難易度 2/5 1〜3時間 初心者へのやさしさ 38/100
graphile/graphile.github.io#401 · コメント 1 件 · リアクション 1 件 ·
-
website: Update details on homepage and sponsor page再び着手できるかも @jemgillam が 1119 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンquick
graphile/graphile.github.io#399 · コメント 4 件 · 担当者 1 名 ·
-
sponsor page: New wording around Grafast needed!再び着手できるかも @jemgillam が 1149 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
graphile/graphile.github.io#393 · リアクション 1 件 · 担当者 1 名 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
graphile/graphile.github.io#280 · コメント 2 件 · リアクション 5 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
graphile/graphile.github.io#273 · コメント 2 件 ·
graphile/graphile.github.io の issue をすべて見る
似ている issue
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
gke-labs/kube-agents#7308 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 62/100
-
chore
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
lugassawan/swe-workbench#841 ·