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 typo in introspection code #5019

Merged
merged 1 commit into from
Jul 15, 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
21 changes: 3 additions & 18 deletions lib/graphql/introspection/schema_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,20 @@ def types
end

def query_type
permitted_root_type("query")
@context.types.query_root
end

def mutation_type
permitted_root_type("mutation")
@context.types.mutation_root
end

def subscription_type
permitted_root_type("subscription")
@context.types.subscription_root
end

def directives
@context.types.directives
end

private

def permitted_root_type(op_type)
case op_type
when "query"
@context.types.query_root
when "mutation"
@context.types.mutation_root
when "subcription"
@context.types.subscription_root
else
nil
end
end
end
end
end
5 changes: 5 additions & 0 deletions spec/graphql/subscriptions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ def to_param
end
end

it "works with the introspection query" do
res = schema.execute("{ __schema { subscriptionType { name } } }")
assert_equal "Subscription", res["data"]["__schema"]["subscriptionType"]["name"]
end

if in_memory_backend_class != FromDefinitionInMemoryBackend # No way to specify this when using IDL
it "supports filtering in the subscription class" do
query_str = "subscription($channel: Int) { filteredStream(channel: $channel) { message } }"
Expand Down