Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#4,388 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
graphql, rails, ruby
Ambito
api, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Ruby
Stelle
5.4k
Fork
1.4k
Merge medio
1g 8h
PR unite (30g)
74

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rmosolgo/graphql-ruby

Tutte le issue di rmosolgo/graphql-ruby

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.