Skip to content

Commit

Permalink
Add test to reproduce bug report #42
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed Jan 25, 2024
1 parent d13d788 commit 79a3672
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
21 changes: 21 additions & 0 deletions spec/graphql/query_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

RSpec.describe "Query without subscriptions" do
subject { BroadcastSchema.execute(query: query) }

let(:query) do
<<~GRAPHQL.strip
query SomeQuery { strategy { id classType } }
GRAPHQL
end

it "works" do
expect(subject["data"]).to eq(
"strategy" => {
"id" => "2134",
"classType" => "strategy",
"__typename": "Strategy",
},
)
end
end
1 change: 0 additions & 1 deletion spec/integrations/rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def self.root
require "anycable-rails"

# Load server to trigger load hooks
require "action_cable/server"
require "action_cable/server/base"
# Only for anycable-rails <1.3.0
unless defined?(::AnyCable::Rails::Connection)
Expand Down
25 changes: 25 additions & 0 deletions spec/support/graphql_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,33 @@ def default_resolver
end
end

class BaseObject < GraphQL::Schema::Object
field :class_type, String, null: false

def class_type
object.class.name.camelize(:lower)
end
end

class StrategyType < BaseObject
field :id, ID, null: false
end

class QueryType < GraphQL::Schema::Object
field :strategy, StrategyType

def strategy
{
id: 2134,
class_type: "strategy",
}
end
end

class AnycableSchema < GraphQL::Schema
use GraphQL::AnyCable

query QueryType
subscription SubscriptionType
end

Expand Down Expand Up @@ -78,4 +102,5 @@ class BroadcastSchema < GraphQL::Schema
use GraphQL::AnyCable, broadcast: true, default_broadcastable: true

subscription Broadcastable::SubscriptionType
query QueryType
end

0 comments on commit 79a3672

Please sign in to comment.