spec/graphql/schema/subscription_spec.rb in graphql-1.9.2 vs spec/graphql/schema/subscription_spec.rb in graphql-1.9.3

- old
+ new

@@ -85,14 +85,22 @@ def update { users: object[:new_users] } end end + # Like above, but doesn't override #subscription, + # to make sure it works without arguments + class NewUsersJoined < BaseSubscription + field :users, [User], null: true, + description: "Includes newly-created users, or all users on the initial load" + end + class Subscription < GraphQL::Schema::Object extend GraphQL::Subscriptions::SubscriptionRoot field :toot_was_tooted, subscription: TootWasTooted field :users_joined, subscription: UsersJoined + field :new_users_joined, subscription: NewUsersJoined end class Mutation < GraphQL::Schema::Object field :toot, Toot, null: false do argument :body, String, required: true @@ -286,9 +294,25 @@ res = exec_query <<-GRAPHQL subscription { tootWasTooted(handle: "matz") { toot { body } + } + } + GRAPHQL + assert_equal({"data" => {}}, res) + assert_equal 1, in_memory_subscription_count + end + + it "works when there are no arguments" do + assert_equal 0, in_memory_subscription_count + + res = exec_query <<-GRAPHQL + subscription { + newUsersJoined { + users { + handle + } } } GRAPHQL assert_equal({"data" => {}}, res) assert_equal 1, in_memory_subscription_count