Sha256: 08f6a1a2243d763082dbf6ee4e2fc5a9e4f5d7a3c97cfe25f87b1f0a39dedf94

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

module GraphQL
  class Query
    # Expose some query-specific info to field resolve functions.
    # It delegates `[]` to the hash that's passed to `GraphQL::Query#initialize`.
    class Context
      attr_accessor :execution_strategy

      # The {GraphQL::Language::Nodes::Field} for the currently-executing field.
      # @return [GraphQL::Language::Nodes::Field]
      attr_accessor :ast_node

      # @return [Array<GraphQL::ExecutionError>] errors returned during execution
      attr_reader :errors

      # @return [GraphQL::Query] The query whose context this is
      attr_reader :query

      # @return [GraphQL::Schema]
      attr_reader :schema

      # Make a new context which delegates key lookup to `values`
      # @param query [GraphQL::Query] the query who owns this context
      # @param values [Hash] A hash of arbitrary values which will be accessible at query-time
      def initialize(query:, values:)
        @query = query
        @schema = query.schema
        @values = values || {}
        @errors = []
      end

      # Lookup `key` from the hash passed to {Schema#execute} as `context`
      def [](key)
        @values[key]
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-0.15.3 lib/graphql/query/context.rb
graphql-0.15.2 lib/graphql/query/context.rb
graphql-0.14.2 lib/graphql/query/context.rb
graphql-0.15.1 lib/graphql/query/context.rb
graphql-0.15.0 lib/graphql/query/context.rb
graphql-0.14.1 lib/graphql/query/context.rb
graphql-0.14.0 lib/graphql/query/context.rb
graphql-0.13.0 lib/graphql/query/context.rb