Class: GraphQL::Query::MergedMask Private

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/query.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first_mask, second_mask) ⇒ MergedMask

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MergedMask.



281
282
283
284
# File 'lib/graphql/query.rb', line 281

def initialize(first_mask, second_mask)
  @first_mask = first_mask
  @second_mask = second_mask
end

Class Method Details

.combine(default_mask, except:, only:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/graphql/query.rb', line 290

def self.combine(default_mask, except:, only:)
  query_mask = if except
    wrap_if_legacy_mask(except)
  elsif only
    InvertedMask.new(wrap_if_legacy_mask(only))
  end

  if query_mask && (default_mask != GraphQL::Schema::NullMask)
    self.new(default_mask, query_mask)
  else
    query_mask || default_mask
  end
end

.wrap_if_legacy_mask(mask) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



304
305
306
307
308
309
310
311
# File 'lib/graphql/query.rb', line 304

def self.wrap_if_legacy_mask(mask)
  if (mask.is_a?(Proc) && mask.arity == 1) || mask.method(:call).arity == 1
    warn("Schema.execute(..., except:) filters now accept two arguments, `(member, ctx)`. One-argument filters are deprecated.")
    LegacyMaskWrap.new(mask)
  else
    mask
  end
end

Instance Method Details

#call(member, ctx) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



286
287
288
# File 'lib/graphql/query.rb', line 286

def call(member, ctx)
  @first_mask.call(member, ctx) || @second_mask.call(member, ctx)
end