Sha256: 820402cdae217883a251e9cd3f32bc0e980670a6f6e7db1537d0269022ad2f7b

Contents?: true

Size: 1.82 KB

Versions: 45

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

module GraphQL
  module Introspection
    class SchemaType < Introspection::BaseObject
      graphql_name "__Schema"
      description "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all "\
                  "available types and directives on the server, as well as the entry points for "\
                  "query, mutation, and subscription operations."

      field :types, [GraphQL::Schema::LateBoundType.new("__Type")], "A list of all types supported by this server.", null: false, scope: false
      field :query_type, GraphQL::Schema::LateBoundType.new("__Type"), "The type that query operations will be rooted at.", null: false
      field :mutation_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server supports mutation, the type that mutation operations will be rooted at."
      field :subscription_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server support subscription, the type that subscription operations will be rooted at."
      field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false, scope: false
      field :description, String, resolver_method: :schema_description

      def schema_description
        context.schema.description
      end

      def types
        @context.warden.reachable_types.sort_by(&:graphql_name)
      end

      def query_type
        permitted_root_type("query")
      end

      def mutation_type
        permitted_root_type("mutation")
      end

      def subscription_type
        permitted_root_type("subscription")
      end

      def directives
        @context.warden.directives
      end

      private

      def permitted_root_type(op_type)
        @context.warden.root_type_for_operation(op_type)
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
graphql-2.1.15 lib/graphql/introspection/schema_type.rb
graphql-1.13.24 lib/graphql/introspection/schema_type.rb
graphql-2.0.32 lib/graphql/introspection/schema_type.rb
graphql-2.1.14 lib/graphql/introspection/schema_type.rb
graphql-2.1.13 lib/graphql/introspection/schema_type.rb
graphql-2.0.31 lib/graphql/introspection/schema_type.rb
graphql-1.13.23 lib/graphql/introspection/schema_type.rb
graphql-2.0.29 lib/graphql/introspection/schema_type.rb
graphql-2.1.12 lib/graphql/introspection/schema_type.rb
graphql-1.13.22 lib/graphql/introspection/schema_type.rb
graphql-2.1.11 lib/graphql/introspection/schema_type.rb
graphql-2.0.28 lib/graphql/introspection/schema_type.rb
graphql-1.13.21 lib/graphql/introspection/schema_type.rb
graphql-2.2.5 lib/graphql/introspection/schema_type.rb
graphql-2.2.4 lib/graphql/introspection/schema_type.rb
graphql-2.2.3 lib/graphql/introspection/schema_type.rb
graphql-2.1.10 lib/graphql/introspection/schema_type.rb
graphql-2.2.2 lib/graphql/introspection/schema_type.rb
graphql-2.1.9 lib/graphql/introspection/schema_type.rb
graphql-2.2.1 lib/graphql/introspection/schema_type.rb