Sha256: e36281f03295d08f3749ef9e915f266d69c6bae19568b9ae85f350d86f57720b

Contents?: true

Size: 590 Bytes

Versions: 7

Compression:

Stored size: 590 Bytes

Contents

require 'graphql'

module GraphQL
  module Cache
    # Custom field class implementation to allow for
    # cache config keyword parameters
    class Field < ::GraphQL::Schema::Field
      # Override #initialize to take a new argument:
      def initialize(
        *args,
        cache: false,
        **kwargs,
        &block
      )
        @cache_config = cache
        super(*args, **kwargs, &block)
      end

      def to_graphql
        field_defn = super # Returns a GraphQL::Field
        field_defn.metadata[:cache] = @cache_config
        field_defn
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
graphql-cache-0.4.0 lib/graphql/cache/field.rb
graphql-cache-0.3.0 lib/graphql/cache/field.rb
graphql-cache-0.2.5 lib/graphql/cache/field.rb
graphql-cache-0.2.4 lib/graphql/cache/field.rb
graphql-cache-0.2.3 lib/graphql/cache/field.rb
graphql-cache-0.2.2 lib/graphql/cache/field.rb
graphql-cache-0.2.1 lib/graphql/cache/field.rb