Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for when multiple field implementations are all hidden #5191

Merged
merged 1 commit into from
Dec 10, 2024
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