Sha256: 428d5422df568748862a41da3ed7b0fd7e2730f00c5f1654327dcbe20c45787e

Contents?: true

Size: 1.03 KB

Versions: 76

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true
module GraphQL
  # There are two ways to apply the deprecated `!` DSL to class-style schema definitions:
  #
  # 1. Scoped by file (CRuby only), add to the top of the file:
  #
  #      using GraphQL::DeprecatedDSL
  #
  #   (This is a "refinement", there are also other ways to scope it.)
  #
  # 2. Global application, add before schema definition:
  #
  #      GraphQL::DeprecatedDSL.activate
  #
  module DeprecatedDSL
    TYPE_CLASSES = [
      GraphQL::Schema::Scalar,
      GraphQL::Schema::Enum,
      GraphQL::Schema::InputObject,
      GraphQL::Schema::Union,
      GraphQL::Schema::Interface,
      GraphQL::Schema::Object,
    ]

    def self.activate
      TYPE_CLASSES.each { |c| c.extend(Methods) }
      GraphQL::Schema::List.include(Methods)
      GraphQL::Schema::NonNull.include(Methods)
    end
    module Methods
      def !
        to_non_null_type
      end
    end

    TYPE_CLASSES.each do |type_class|
      refine type_class.singleton_class do
        include Methods
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
graphql-1.11.10 lib/graphql/deprecated_dsl.rb
graphql-1.11.9 lib/graphql/deprecated_dsl.rb
graphql-1.11.8 lib/graphql/deprecated_dsl.rb
graphql-1.11.7 lib/graphql/deprecated_dsl.rb
graphql-1.11.6 lib/graphql/deprecated_dsl.rb
graphql-1.8.18 lib/graphql/deprecated_dsl.rb
graphql-1.11.5 lib/graphql/deprecated_dsl.rb
graphql-1.11.4 lib/graphql/deprecated_dsl.rb
graphql-1.11.3 lib/graphql/deprecated_dsl.rb
graphql-1.11.2 lib/graphql/deprecated_dsl.rb
graphql-1.10.14 lib/graphql/deprecated_dsl.rb
graphql-1.11.1 lib/graphql/deprecated_dsl.rb
graphql-1.10.13 lib/graphql/deprecated_dsl.rb
graphql-1.11.0 lib/graphql/deprecated_dsl.rb
graphql-1.10.12 lib/graphql/deprecated_dsl.rb
graphql-1.9.21 lib/graphql/deprecated_dsl.rb
graphql-1.10.11 lib/graphql/deprecated_dsl.rb
graphql-1.9.20 lib/graphql/deprecated_dsl.rb
graphql-1.10.10 lib/graphql/deprecated_dsl.rb
graphql-1.10.9 lib/graphql/deprecated_dsl.rb