Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Lookahead's `selects?` returns false for a field that is visible in `#selections` on a Union type

オープン
#4,388 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
graphql, rails, ruby
領域
api, backend

調査の方向性

Start in Resolvers::SavedRepliesTreeResolver and reproduce the query with the Union type, comparing lookahead.selects?(:attachment) with lookahead.selections. Read the lookahead behavior for union selections and verify that attachment is recognized by selects? while the existing selections remain visible.

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

説明

Describe the bug

Inside my resolver, whenever I call .selects?(:attachment), it returns false. Although the :attachment field is present whenever I do lookahead.selections.map(&:name) I find that the :attachment field is present

Versions

graphql: 1.13.15
rails: 6.0.3

GraphQL schema

# Types
class SavedReplyFolderType < ::Types::BaseObject
  # fields that are not :attachment
end

class SavedReplyType < ::Types::BaseObject
  # other fields
  field :attachment, ::Types::AttachmentType, null: true
end

class SavedReplyLeafUnion < ::Types::BaseUnion
  possible_types Types::SavedReplyType, Types::SavedReplyFolderType

  def self.resolve_type(object, context)
    if object.is_a?(::SavedReply)
      Types::SavedReplyType
    elsif object.is_a?(::SavedReplyFolder)
      Types::SavedReplyFolderType
    end
  end
end


# Resolvers
# Resolver for [SavedReplyLeafUnion]
module Resolvers
  class SavedRepliesTreeResolver < BaseResolver
    extras [:lookahead]
    def resolve(lookahead:)
       # try accessing lookahead here
    end
  end
end

GraphQL query

query savedRepliesTree {
  app {
    savedRepliesTree {
      __typename
      ... on SavedReply {
				attachment {
          id
        }
      }
      ... on SavedReplyFolder {
        id
      }
    }
  }
}

Steps to reproduce

use byebug inside the resolver
Try doing

(byebug) lookahead.selects?(:attachment)
false

to find that the attachment cannot be found on the lookahead

but whenever you do

(byebug) lookahead.selections.map(&:name)
[:__typename, :attachment, :id]

You'll find that the attachment field exists

Expected behavior

lookahead.selects?(:attachment) should return true

主要言語
Ruby
スター
5.4k
フォーク
1.4k
平均マージ
1日 8時間
マージ済み PR(30日)
74

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rmosolgo/graphql-ruby のほかの issue

rmosolgo/graphql-ruby の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

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

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