Skip to content

Commit

Permalink
Support empty operation name with redis.rb v5 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasgaraev authored Aug 3, 2023
1 parent 2543127 commit 2f3217e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/graphql/subscriptions/anycable_subscriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def write_subscription(query, events)
query_string: query.query_string,
variables: query.provided_variables.to_json,
context: @serializer.dump(context.to_h),
operation_name: query.operation_name,
operation_name: query.operation_name.to_s,
events: events.map { |e| [e.topic, e.fingerprint] }.to_h.to_json,
}

Expand Down
22 changes: 22 additions & 0 deletions spec/graphql/anycable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@
end
end

context "with empty operation name" do
subject do
AnycableSchema.execute(
query: query,
context: { channel: channel, subscription_id: subscription_id },
variables: {},
operation_name: nil,
)
end

let(:query) do
<<~GRAPHQL
subscription { productUpdated { id } }
GRAPHQL
end

it "subscribes channel to stream updates from GraphQL subscription" do
subject
expect(channel).to have_received(:stream_from).with("graphql-subscriptions:#{fingerprint}")
end
end

describe ".delete_channel_subscriptions" do
before do
GraphQL::AnyCable.config.use_client_provided_uniq_id = false
Expand Down

0 comments on commit 2f3217e

Please sign in to comment.