graphile / graphile/graphile.github.io

Fix relation snippet in why-nullable

オープン
#69 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
important quick
主要言語
SCSS
スター
27
フォーク
126
PR マージ指標
30日以内にマージされた PR はありません

説明

https://www.graphile.org/postgraphile/why-nullable/

Currently the snippet (incorrectly) marks all relations as non-nullable. Should only apply if the columns themselves are non-nullable.

Something like this: (needs testing)

```js
module.exports = function NonNullRelationsPlugin(builder) {
builder.hook('GraphQLObjectType:fields:field', (field, build, context) => {
const { isPgForwardRelationField, pgFieldIntrospection } = context.scope;
if (isPgForwardRelationField) {
const linkedAttributeNums = pgFieldIntrospection.keyAttributeNums;
const relationIsNotNull = pgFieldIntrospection.class.attributes.filter(
attr => linkedAttributeNums.indexOf(attr.num) >= 0
).every(attr => attr.isNotNull || attr.type.domainIsNotNull);

if (relationIsNotNull) {
return {
...field,
type: new build.graphql.GraphQLNonNull(field.type),
};
}
}

return field;
});
};
```

HT @enisdenjo

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start with the why-nullable page linked in the issue and inspect the embedded NonNullRelationsPlugin snippet. Verify its behavior for relations backed by nullable and non-nullable columns, then update the example so only relations whose linked columns are non-nullable are marked non-null; add or run the relevant checks if the project provides them.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
graphql, javascript
領域
documentation
issue の種類
ドキュメント
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。