Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#4,388 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
graphql, rails, ruby
Lĩnh vực
api, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Ruby
Star
5.4k
Fork
1.4k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
74

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rmosolgo/graphql-ruby

Tất cả issue của rmosolgo/graphql-ruby

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.