以下の内容はhttps://blog.utgw.net/entry/2024/03/01/131631より取得しました。


GraphQL Cursor Connectionにおけるedgeのnodeフィールドの型は必ずしもNode interfaceを実装していなくてもよい

タイトルが全てです。

GraphQL Cursor Connectionの仕様の3.1.1節には以下のような注意書きがあります。

The naming echoes that of the “Node” interface and “node” root field as described in a later section of this spec. Spec-compliant clients can perform certain optimizations if this field returns an object that implements Node, however, this is not a strict requirement for conforming.

https://relay.dev/graphql/connections.htm#note-e0232

注意書きをざっくり訳すと以下のようになります。

  • この node という名前は、GraphQL Object IdenrificationにおけるNode interfaceや node クエリを想起させる
  • が、connectionのEdgeの node フィールドの型は、必ずしも Node interfaceを実装していなくてもよい
    • もちろん、Node interfaceになっているほうが最適化が効きやすいだろう

多くの場合はEdgeのnodeがそのまま Node interfaceを実装するようになっていても支障はないだろうけど、必ずしも Node interfaceである必要はないよ、というのが伝えたいことでした。




以上の内容はhttps://blog.utgw.net/entry/2024/03/01/131631より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14