Sha256: 688921f1f1a9783aa375aa5dfff539fafba6bf07ebe6b408982c0fa0f31754ee

Contents?: true

Size: 1.31 KB

Versions: 21

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true
module GraphQL
  module Introspection
    class EntryPoints < Introspection::BaseObject
      field :__schema, GraphQL::Schema::LateBoundType.new("__Schema"), "This GraphQL schema", null: false
      field :__type, GraphQL::Schema::LateBoundType.new("__Type"), "A type in the GraphQL system", null: true do
        argument :name, String, required: true
      end

      def __schema
        # Apply wrapping manually since this field isn't wrapped by instrumentation
        schema = @context.query.schema
        schema_type = schema.introspection_system.schema_type
        schema_type.metadata[:type_class].authorized_new(schema, @context)
      end

      def __type(name:)
        type = context.warden.get_type(name)

        if type && context.interpreter?
          type = type.metadata[:type_class] || raise("Invariant: interpreter requires class-based type for #{name}")
        end

        # The interpreter provides this wrapping, other execution doesnt, so support both.
        if type && !context.interpreter?
          # Apply wrapping manually since this field isn't wrapped by instrumentation
          type_type = context.schema.introspection_system.type_type
          type = type_type.metadata[:type_class].authorized_new(type, context)
        end
        type
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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