Skip to content

Commit

Permalink
Merge pull request #5019 from rmosolgo/fix-subscription-root-type
Browse files Browse the repository at this point in the history
Fix typo in introspection code
  • Loading branch information
rmosolgo authored Jul 15, 2024
2 parents 43b6760 + cccda3c commit 2690be9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
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

0 comments on commit 2690be9

Please sign in to comment.