spec/dummy/app/channels/graphql_channel.rb in graphql-1.8.18 vs spec/dummy/app/channels/graphql_channel.rb in graphql-1.9.0.pre1

- old
+ new

@@ -1,22 +1,30 @@ # frozen_string_literal: true class GraphqlChannel < ActionCable::Channel::Base - QueryType = GraphQL::ObjectType.define do - name "Query" - field :value, types.Int, resolve: Proc.new { 3 } + class QueryType < GraphQL::Schema::Object + field :value, Integer, null: false + def value + 3 + end end - SubscriptionType = GraphQL::ObjectType.define do - name "Subscription" - field :payload, PayloadType do - argument :id, !types.ID - end + class PayloadType < GraphQL::Schema::Object + field :value, Integer, null: false end - PayloadType = GraphQL::ObjectType.define do - name "Payload" - field :value, types.Int + class SubscriptionType < GraphQL::Schema::Object + if TESTING_INTERPRETER + extend GraphQL::Subscriptions::SubscriptionRoot + end + + field :payload, PayloadType, null: false do + argument :id, ID, required: true + end + + def payload(id:) + id + end end # Wacky behavior around the number 4 # so we can confirm it's used by the UI module CustomSerializer @@ -40,9 +48,12 @@ class GraphQLSchema < GraphQL::Schema query(QueryType) subscription(SubscriptionType) use GraphQL::Subscriptions::ActionCableSubscriptions, serializer: CustomSerializer + if TESTING_INTERPRETER + use GraphQL::Execution::Interpreter + end end def subscribed @subscription_ids = [] end