Sha256: 40b77b556820a7b95ae266caa8e48b91b1da2d3b9d80d87739814a20a3ebc25b

Contents?: true

Size: 1.34 KB

Versions: 25

Compression:

Stored size: 1.34 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" do
        argument :name, String
      end

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

      def __type(name:)
        return unless context.warden.reachable_type?(name)
        type = context.warden.get_type(name)

        if type && context.interpreter? && !type.is_a?(Module)
          type = type.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.types["__Type"]
          type = type_type.type_class.authorized_new(type, context)
        end
        type
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
graphql-1.13.23 lib/graphql/introspection/entry_points.rb
graphql-1.13.22 lib/graphql/introspection/entry_points.rb
graphql-1.13.21 lib/graphql/introspection/entry_points.rb
graphql-1.13.20 lib/graphql/introspection/entry_points.rb
graphql-1.13.19 lib/graphql/introspection/entry_points.rb
graphql-1.13.18 lib/graphql/introspection/entry_points.rb
graphql-1.13.17 lib/graphql/introspection/entry_points.rb
graphql-1.13.16 lib/graphql/introspection/entry_points.rb
graphql-1.13.15 lib/graphql/introspection/entry_points.rb
graphql-1.13.14 lib/graphql/introspection/entry_points.rb
graphql-1.13.13 lib/graphql/introspection/entry_points.rb
graphql_cody-1.13.0 lib/graphql/introspection/entry_points.rb
graphql-1.13.12 lib/graphql/introspection/entry_points.rb
graphql-1.13.11 lib/graphql/introspection/entry_points.rb
graphql-1.13.10 lib/graphql/introspection/entry_points.rb
graphql-1.13.9 lib/graphql/introspection/entry_points.rb
graphql-1.13.8 lib/graphql/introspection/entry_points.rb
graphql-1.13.7 lib/graphql/introspection/entry_points.rb
graphql-1.13.6 lib/graphql/introspection/entry_points.rb
graphql-1.13.5 lib/graphql/introspection/entry_points.rb