Sha256: 68f969c021e9aeea3cf49f81b0231b5eadf0ea95467fc896f6d8e02ac66c8a13

Contents?: true

Size: 1.83 KB

Versions: 22

Compression:

Stored size: 1.83 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
      field :queryType, GraphQL::Schema::LateBoundType.new("__Type"), "The type that query operations will be rooted at.", null: false
      field :mutationType, GraphQL::Schema::LateBoundType.new("__Type"), "If this server supports mutation, the type that mutation operations will be rooted at.", null: true
      field :subscriptionType, GraphQL::Schema::LateBoundType.new("__Type"), "If this server support subscription, the type that subscription operations will be rooted at.", null: true
      field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false

      def types
        types = @context.warden.types
        if context.interpreter?
          types.map { |t| t.metadata[:type_class] || raise("Invariant: can't introspect non-class-based type: #{t}") }
        else
          types
        end
      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.schema.directives.values
      end

      private

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
graphql-1.9.16 lib/graphql/introspection/schema_type.rb
graphql-1.9.15 lib/graphql/introspection/schema_type.rb
graphql-1.9.14 lib/graphql/introspection/schema_type.rb
graphql-1.10.0.pre1 lib/graphql/introspection/schema_type.rb
graphql-1.9.13 lib/graphql/introspection/schema_type.rb
graphql-1.9.12 lib/graphql/introspection/schema_type.rb
graphql-1.9.11 lib/graphql/introspection/schema_type.rb
graphql-1.9.10 lib/graphql/introspection/schema_type.rb
graphql-1.9.9 lib/graphql/introspection/schema_type.rb
graphql-1.9.8 lib/graphql/introspection/schema_type.rb
graphql-1.9.7 lib/graphql/introspection/schema_type.rb
graphql-1.9.6 lib/graphql/introspection/schema_type.rb
graphql-1.9.5 lib/graphql/introspection/schema_type.rb
graphql-1.9.4 lib/graphql/introspection/schema_type.rb
graphql-1.9.3 lib/graphql/introspection/schema_type.rb
graphql-1.9.2 lib/graphql/introspection/schema_type.rb
graphql-1.9.1 lib/graphql/introspection/schema_type.rb
graphql-1.9.0 lib/graphql/introspection/schema_type.rb
graphql-1.9.0.pre4 lib/graphql/introspection/schema_type.rb
graphql-1.9.0.pre3 lib/graphql/introspection/schema_type.rb