Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/graphql/schema/visibility/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def field(owner, field_name)
end
end
end
visible_f.ensure_loaded
visible_f&.ensure_loaded
elsif f && @cached_visible_fields[owner][f.ensure_loaded]
f
else
Expand Down
25 changes: 25 additions & 0 deletions spec/graphql/schema/visibility/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,29 @@ class Query < GraphQL::Schema::Object
loaded_type_names = query.types.loaded_types.map(&:graphql_name).reject { |n| n.start_with?("__") }.sort
assert_equal ["Boolean", "Query", "String", "Thing"], loaded_type_names
end


describe "when multiple field implementations are all hidden" do
class EnsureLoadedFixSchema < GraphQL::Schema
class BaseField < GraphQL::Schema::Field
def visible?(...)
false
end
end
class Query < GraphQL::Schema::Object
field_class(BaseField)

field :f1, String
field :f1, String
end

query(Query)
use GraphQL::Schema::Visibility
end

it "handles it without raising an error" do
result = EnsureLoadedFixSchema.execute("{ f1 }")
assert 1, result["errors"].size
end
end
end
Loading