Sha256: 851db4aa574d5732407c0c1f06dbb9efc7e928979f0fc809be4fea9aad059553

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module StaticValidation
    class SubscriptionRootExists
      include GraphQL::StaticValidation::Message::MessageHelper

      def validate(context)
        return if context.schema.subscription

        visitor = context.visitor

        visitor[GraphQL::Language::Nodes::OperationDefinition].enter << ->(ast_node, prev_ast_node) {
          if ast_node.operation_type == 'subscription'
            context.errors << message('Schema is not configured for subscriptions', ast_node, context: context)
            return GraphQL::Language::Visitor::SKIP
          end
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-1.4.0 lib/graphql/static_validation/rules/subscription_root_exists.rb
graphql-1.3.0 lib/graphql/static_validation/rules/subscription_root_exists.rb