Class: GraphQL::Schema::Field

Inherits:
Object
  • Object
show all
Includes:
Member::AcceptsDefinition, Member::CachedGraphQLDefinition, Member::HasArguments, Member::HasPath
Defined in:
lib/graphql/schema/field.rb,
lib/graphql/schema/field/scope_extension.rb,
lib/graphql/schema/field/connection_extension.rb

Direct Known Subclasses

Types::Relay::BaseField

Defined Under Namespace

Classes: ConnectionExtension, ScopeExtension

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Member::HasPath

#path

Methods included from Member::HasArguments

#add_argument, #argument, #argument_class, #argument_with_loads, #arguments, #own_arguments

Methods included from Member::CachedGraphQLDefinition

#graphql_definition, #initialize_copy

Constructor Details

#initialize(type: nil, name: nil, owner: nil, null: nil, field: nil, function: nil, description: nil, deprecation_reason: nil, method: nil, hash_key: nil, resolver_method: nil, resolve: nil, connection: nil, max_page_size: nil, scope: nil, introspection: false, camelize: true, trace: nil, complexity: 1, extras: [], extensions: [], resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, arguments: {}, &definition_block) ⇒ Field

Returns a new instance of Field

Parameters:

  • name (Symbol)

    The underscore-cased version of this field name (will be camelized for the GraphQL API)

  • type (Class, GraphQL::BaseType, Array)

    The return type of this field

  • owner (Class)

    The type that this field belongs to

  • null (Boolean)

    true if this field may return null, false if it is never null

  • description (String)

    Field description

  • deprecation_reason (String)

    If present, the field is marked “deprecated” with this message

  • method (Symbol)

    The method to call on the underlying object to resolve this field (defaults to name)

  • hash_key (String, Symbol)

    The hash key to lookup on the underlying object (if its a Hash) to resolve this field (defaults to name or name.to_s)

  • resolver_method (Symbol)

    The method on the type to call to resolve this field (defaults to name)

  • connection (Boolean)

    true if this field should get automagic connection behavior; default is to infer by *Connection in the return type name

  • max_page_size (Integer)

    For connections, the maximum number of items to return from this field

  • introspection (Boolean)

    If true, this field will be marked as #introspection? and the name may begin with __

  • resolve (<#call(obj, args, ctx)>)

    deprecated for compatibility with <1.8.0

  • field (GraphQL::Field, GraphQL::Schema::Field)

    deprecated for compatibility with <1.8.0

  • function (GraphQL::Function)

    deprecated for compatibility with <1.8.0

  • resolver_class (Class)

    (Private) A Resolver which this field was derived from. Use resolver: to create a field with a resolver.

  • arguments ({String=>GraphQL::Schema::Argument, Hash})

    Arguments for this field (may be added in the block, also)

  • camelize (Boolean)

    If true, the field name will be camelized when building the schema

  • complexity (Numeric)

    When provided, set the complexity for this field

  • scope (Boolean)

    If true, the return type’s .scope_items method will be called on the return value

  • subscription_scope (Symbol, String)

    A key in context which will be used to scope subscription payloads

  • extensions (Array<Class>)

    Named extensions to apply to this field (see also #extension)

  • trace (Boolean)

    If true, a Tracing tracer will measure this scalar field



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/graphql/schema/field.rb', line 164

def initialize(type: nil, name: nil, owner: nil, null: nil, field: nil, function: nil, description: nil, deprecation_reason: nil, method: nil, hash_key: nil, resolver_method: nil, resolve: nil, connection: nil, max_page_size: nil, scope: nil, introspection: false, camelize: true, trace: nil, complexity: 1, extras: [], extensions: [], resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, arguments: {}, &definition_block)
  if name.nil?
    raise ArgumentError, "missing first `name` argument or keyword `name:`"
  end
  if !(field || function || resolver_class)
    if type.nil?
      raise ArgumentError, "missing second `type` argument or keyword `type:`"
    end
    if null.nil?
      raise ArgumentError, "missing keyword argument null:"
    end
  end
  if (field || function || resolve) && extras.any?
    raise ArgumentError, "keyword `extras:` may only be used with method-based resolve and class-based field such as mutation class, please remove `field:`, `function:` or `resolve:`"
  end
  @original_name = name
  @underscored_name = -Member::BuildType.underscore(name.to_s)
  @name = -(camelize ? Member::BuildType.camelize(name.to_s) : name.to_s)
  @description = description
  if field.is_a?(GraphQL::Schema::Field)
    raise ArgumentError, "Instead of passing a field as `field:`, use `add_field(field)` to add an already-defined field."
  else
    @field = field
  end
  @function = function
  @resolve = resolve
  @deprecation_reason = deprecation_reason

  if method && hash_key
    raise ArgumentError, "Provide `method:` _or_ `hash_key:`, not both. (called with: `method: #{method.inspect}, hash_key: #{hash_key.inspect}`)"
  end

  if resolver_method
    if method
      raise ArgumentError, "Provide `method:` _or_ `resolver_method:`, not both. (called with: `method: #{method.inspect}, resolver_method: #{resolver_method.inspect}`)"
    end

    if hash_key
      raise ArgumentError, "Provide `hash_key:` _or_ `resolver_method:`, not both. (called with: `hash_key: #{hash_key.inspect}, resolver_method: #{resolver_method.inspect}`)"
    end
  end

  # TODO: I think non-string/symbol hash keys are wrongly normalized (eg `1` will not work)
  method_name = method || hash_key || @underscored_name
  resolver_method ||= @underscored_name

  @method_str = method_name.to_s
  @method_sym = method_name.to_sym
  @resolver_method = resolver_method
  @complexity = complexity
  @return_type_expr = type
  @return_type_null = null
  @connection = connection
  @max_page_size = max_page_size
  @introspection = introspection
  @extras = extras
  @resolver_class = resolver_class
  @scope = scope
  @trace = trace
  @relay_node_field = relay_node_field
  @relay_nodes_field = relay_nodes_field

  # Override the default from HasArguments
  @own_arguments = {}
  arguments.each do |name, arg|
    if arg.is_a?(Hash)
      argument(name: name, **arg)
    else
      @own_arguments[name] = arg
    end
  end

  @owner = owner
  @subscription_scope = subscription_scope

  # Do this last so we have as much context as possible when initializing them:
  @extensions = []
  if extensions.any?
    self.extensions(extensions)
  end
  # This should run before connection extension,
  # but should it run after the definition block?
  if scoped?
    self.extension(ScopeExtension)
  end
  # The problem with putting this after the definition_block
  # is that it would override arguments
  if connection?
    self.extension(ConnectionExtension)
  end

  if definition_block
    if definition_block.arity == 1
      yield self
    else
      instance_eval(&definition_block)
    end
  end
end

Instance Attribute Details

#deprecation_reasonString?

Returns If present, the field is marked as deprecated with this documentation

Returns:

  • (String, nil)

    If present, the field is marked as deprecated with this documentation



25
26
27
# File 'lib/graphql/schema/field.rb', line 25

def deprecation_reason
  @deprecation_reason
end

#description(text = nil) ⇒ String

Parameters:

  • text (String) (defaults to: nil)

Returns:

  • (String)


266
267
268
269
270
271
272
# File 'lib/graphql/schema/field.rb', line 266

def description(text = nil)
  if text
    @description = text
  else
    @description
  end
end

#extrasArray<Symbol> (readonly)

Returns:

  • (Array<Symbol>)


50
51
52
# File 'lib/graphql/schema/field.rb', line 50

def extras
  @extras
end

#max_page_sizeInteger? (readonly)

Returns Applied to connections if present

Returns:

  • (Integer, nil)

    Applied to connections if present



327
328
329
# File 'lib/graphql/schema/field.rb', line 327

def max_page_size
  @max_page_size
end

#method_strString (readonly)

Returns Method or hash key on the underlying object to look up

Returns:

  • (String)

    Method or hash key on the underlying object to look up



31
32
33
# File 'lib/graphql/schema/field.rb', line 31

def method_str
  @method_str
end

#method_symSymbol (readonly)

Returns Method or hash key on the underlying object to look up

Returns:

  • (Symbol)

    Method or hash key on the underlying object to look up



28
29
30
# File 'lib/graphql/schema/field.rb', line 28

def method_sym
  @method_sym
end

#nameString (readonly) Also known as: graphql_name

Returns the GraphQL name for this field, camelized unless camelize: false is provided

Returns:

  • (String)

    the GraphQL name for this field, camelized unless camelize: false is provided



19
20
21
# File 'lib/graphql/schema/field.rb', line 19

def name
  @name
end

#original_nameSymobol (readonly)

Returns the original name of the field, passed in by the user

Returns:

  • (Symobol)

    the original name of the field, passed in by the user



40
41
42
# File 'lib/graphql/schema/field.rb', line 40

def original_name
  @original_name
end

#ownerClass (readonly)

Returns The type that this field belongs to

Returns:

  • (Class)

    The type that this field belongs to



37
38
39
# File 'lib/graphql/schema/field.rb', line 37

def owner
  @owner
end

#resolver_methodSymbol (readonly)

Returns The method on the type to look up

Returns:

  • (Symbol)

    The method on the type to look up



34
35
36
# File 'lib/graphql/schema/field.rb', line 34

def resolver_method
  @resolver_method
end

#subscription_scopeString? (readonly)

Returns:

  • (String, nil)


56
57
58
# File 'lib/graphql/schema/field.rb', line 56

def subscription_scope
  @subscription_scope
end

#traceBoolean (readonly)

Returns Apply tracing to this field? (Default: skip scalars, this is the override value)

Returns:

  • (Boolean)

    Apply tracing to this field? (Default: skip scalars, this is the override value)



53
54
55
# File 'lib/graphql/schema/field.rb', line 53

def trace
  @trace
end

Class Method Details

.from_options(name = nil, type = nil, desc = nil, resolver: nil, mutation: nil, subscription: nil, **kwargs, &block) ⇒ GraphQL::Schema:Field

Create a field instance from a list of arguments, keyword arguments, and a block.

This method implements prioritization between the resolver or mutation defaults and the local overrides via other keywords.

It also normalizes positional arguments into keywords for #initialize.

Parameters:

  • resolver (Class)

    A Resolver class to use for field configuration

  • mutation (Class)

    A Mutation class to use for field configuration

  • subscription (Class)

    A Subscription class to use for field configuration

Returns:

  • (GraphQL::Schema:Field)

    an instance of `self

See Also:

  • for other options


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/graphql/schema/field.rb', line 69

def self.from_options(name = nil, type = nil, desc = nil, resolver: nil, mutation: nil, subscription: nil,**kwargs, &block)
  if kwargs[:field]
    if kwargs[:field] == GraphQL::Relay::Node.field
      warn("Legacy-style `GraphQL::Relay::Node.field` is being added to a class-based type. See `GraphQL::Types::Relay::NodeField` for a replacement.")
      return GraphQL::Types::Relay::NodeField
    elsif kwargs[:field] == GraphQL::Relay::Node.plural_field
      warn("Legacy-style `GraphQL::Relay::Node.plural_field` is being added to a class-based type. See `GraphQL::Types::Relay::NodesField` for a replacement.")
      return GraphQL::Types::Relay::NodesField
    end
  end

  if (parent_config = resolver || mutation || subscription)
    # Get the parent config, merge in local overrides
    kwargs = parent_config.field_options.merge(kwargs)
    # Add a reference to that parent class
    kwargs[:resolver_class] = parent_config
  end

  if name
    kwargs[:name] = name
  end

  if !type.nil?
    if type.is_a?(GraphQL::Field)
      raise ArgumentError, "A GraphQL::Field was passed as the second argument, use the `field:` keyword for this instead."
    end
    if desc
      if kwargs[:description]
        raise ArgumentError, "Provide description as a positional argument or `description:` keyword, but not both (#{desc.inspect}, #{kwargs[:description].inspect})"
      end

      kwargs[:description] = desc
      kwargs[:type] = type
    elsif (kwargs[:field] || kwargs[:function] || resolver || mutation) && type.is_a?(String)
      # The return type should be copied from `field` or `function`, and the second positional argument is the description
      kwargs[:description] = type
    else
      kwargs[:type] = type
    end
  end
  new(**kwargs, &block)
end

Instance Method Details

#accessible?(context) ⇒ Boolean

Returns:

  • (Boolean)


412
413
414
415
416
417
418
# File 'lib/graphql/schema/field.rb', line 412

def accessible?(context)
  if @resolver_class
    @resolver_class.accessible?(context)
  else
    true
  end
end

#authorized?(object, context) ⇒ Boolean

Returns:

  • (Boolean)


420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/graphql/schema/field.rb', line 420

def authorized?(object, context)
  self_auth = if @resolver_class
    @resolver_class.authorized?(object, context)
  else
    true
  end

  if self_auth
    # Faster than `.any?`
    arguments.each_value do |arg|
      if !arg.authorized?(object, context)
        return false
      end
    end
    true
  else
    false
  end
end

#complexity(new_complexity) ⇒ Object



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/graphql/schema/field.rb', line 308

def complexity(new_complexity)
  case new_complexity
  when Proc
    if new_complexity.parameters.size != 3
      fail(
        "A complexity proc should always accept 3 parameters: ctx, args, child_complexity. "\
        "E.g.: complexity ->(ctx, args, child_complexity) { child_complexity * args[:limit] }"
      )
    else
      @complexity = new_complexity
    end
  when Numeric
    @complexity = new_complexity
  else
    raise("Invalid complexity: #{new_complexity.inspect} on #{@name}")
  end
end

#connection?Boolean

Can be set with connection: true|false or inferred from a type name ending in *Connection

Returns:

  • (Boolean)

    if true, this field will be wrapped with Relay connection behavior



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/graphql/schema/field.rb', line 114

def connection?
  if @connection.nil?
    # Provide default based on type name
    return_type_name = if (contains_type = @field || @function)
      Member::BuildType.to_type_name(contains_type.type)
    elsif @return_type_expr
      Member::BuildType.to_type_name(@return_type_expr)
    else
      # As a last ditch, try to force loading the return type:
      type.unwrap.name
    end
    @connection = return_type_name.end_with?("Connection")
  else
    @connection
  end
end

#extension(extension, options = nil) ⇒ Object

Add extension to this field, initialized with options if provided.

Parameters:

  • extension (Class)

    subclass of Schema::Fieldextension

  • options (Object) (defaults to: nil)

    if provided, given as options: when initializing extension.



304
305
306
# File 'lib/graphql/schema/field.rb', line 304

def extension(extension, options = nil)
  extensions([{extension => options}])
end

#extensions(new_extensions = nil) ⇒ Array<GraphQL::Schema::FieldExtension>

Read extension instances from this field, or add new classes/options to be initialized on this field.

Parameters:

  • extensions (Array<Class>, Hash<Class => Object>)

    Add extensions to this field

Returns:



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/graphql/schema/field.rb', line 279

def extensions(new_extensions = nil)
  if new_extensions.nil?
    # Read the value
    @extensions
  else
    # Normalize to a Hash of {name => options}
    extensions_with_options = if new_extensions.last.is_a?(Hash)
      new_extensions.pop
    else
      {}
    end
    new_extensions.each do |f|
      extensions_with_options[f] = nil
    end

    # Initialize each class and stash the instance
    extensions_with_options.each do |extension_class, options|
      @extensions << extension_class.new(field: self, options: options)
    end
  end
end

#fetch_extra(extra_name, ctx) ⇒ Object



559
560
561
562
563
564
565
566
567
# File 'lib/graphql/schema/field.rb', line 559

def fetch_extra(extra_name, ctx)
  if extra_name != :path && respond_to?(extra_name)
    self.public_send(extra_name)
  elsif ctx.respond_to?(extra_name)
    ctx.public_send(extra_name)
  else
    raise NotImplementedError, "Unknown field extra for #{self.path}: #{extra_name.inspect}"
  end
end

#resolve(object, args, ctx) ⇒ Object

This method is called by the interpreter for each field. You can extend it in your base field classes.

Parameters:



475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
# File 'lib/graphql/schema/field.rb', line 475

def resolve(object, args, ctx)
  if @resolve_proc
    raise "Can't run resolve proc for #{path} when using GraphQL::Execution::Interpreter"
  end
  begin
    # Unwrap the GraphQL object to get the application object.
    application_object = object.object
    if self.authorized?(application_object, ctx)
      # Apply field extensions
      with_extensions(object, args, ctx) do |extended_obj, extended_args|
        field_receiver = if @resolver_class
          resolver_obj = if extended_obj.is_a?(GraphQL::Schema::Object)
            extended_obj.object
          else
            extended_obj
          end
          @resolver_class.new(object: resolver_obj, context: ctx)
        else
          extended_obj
        end

        if field_receiver.respond_to?(@resolver_method)
          # Call the method with kwargs, if there are any
          if extended_args.any?
            field_receiver.public_send(@resolver_method, **extended_args)
          else
            field_receiver.public_send(@resolver_method)
          end
        else
          resolve_field_method(field_receiver, extended_args, ctx)
        end
      end
    else
      err = GraphQL::UnauthorizedFieldError.new(object: application_object, type: object.class, context: ctx, field: self)
      ctx.schema.unauthorized_field(err)
    end
  rescue GraphQL::UnauthorizedFieldError => err
    err.field ||= self
    ctx.schema.unauthorized_field(err)
  rescue GraphQL::UnauthorizedError => err
    ctx.schema.unauthorized_object(err)
  end
rescue GraphQL::ExecutionError => err
  err
end

#resolve_field(obj, args, ctx) ⇒ Object

Implement Field’s resolve API.

Eventually, we might hook up field instances to execution in another way. TBD.



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/graphql/schema/field.rb', line 444

def resolve_field(obj, args, ctx)
  ctx.schema.after_lazy(obj) do |after_obj|
    # First, apply auth ...
    query_ctx = ctx.query.context
    # Some legacy fields can have `nil` here, not exactly sure why.
    # @see https://github.com/rmosolgo/graphql-ruby/issues/1990 before removing
    inner_obj = after_obj && after_obj.object
    if authorized?(inner_obj, query_ctx)
      ruby_args = to_ruby_args(after_obj, args, ctx)
      # Then if it passed, resolve the field
      if @resolve_proc
        # Might be nil, still want to call the func in that case
        with_extensions(inner_obj, ruby_args, query_ctx) do |extended_obj, extended_args|
          # Pass the GraphQL args here for compatibility:
          @resolve_proc.call(extended_obj, args, ctx)
        end
      else
        public_send_field(after_obj, ruby_args, ctx)
      end
    else
      err = GraphQL::UnauthorizedFieldError.new(object: inner_obj, type: obj.class, context: ctx, field: self)
      query_ctx.schema.unauthorized_field(err)
    end
  end
end

#resolve_field_method(obj, ruby_kwargs, ctx) ⇒ Object

Find a way to resolve this field, checking:

  • Hash keys, if the wrapped object is a hash;
  • A method on the wrapped object;
  • Or, raise not implemented.

This can be overridden by defining a method on the object type.

Parameters:



531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/graphql/schema/field.rb', line 531

def resolve_field_method(obj, ruby_kwargs, ctx)
  if obj.object.is_a?(Hash)
    inner_object = obj.object
    if inner_object.key?(@method_sym)
      inner_object[@method_sym]
    else
      inner_object[@method_str]
    end
  elsif obj.object.respond_to?(@method_sym)
    if ruby_kwargs.any?
      obj.object.public_send(@method_sym, **ruby_kwargs)
    else
      obj.object.public_send(@method_sym)
    end
  else
    raise <<-ERR
  Failed to implement #{@owner.graphql_name}.#{@name}, tried:

  - `#{obj.class}##{@resolver_method}`, which did not exist
  - `#{obj.object.class}##{@method_sym}`, which did not exist
  - Looking up hash key `#{@method_sym.inspect}` or `#{@method_str.inspect}` on `#{obj.object}`, but it wasn't a Hash

  To implement this field, define one of the methods above (and check for typos)
  ERR
  end
end

#resolverClass? Also known as: mutation

Returns The Resolver this field was derived from, if there is one

Returns:

  • (Class, nil)

    The Resolver this field was derived from, if there is one



43
44
45
# File 'lib/graphql/schema/field.rb', line 43

def resolver
  @resolver_class
end

#scoped?Boolean

Returns if true, the return type’s .scope_items method will be applied to this field’s return value

Returns:

  • (Boolean)

    if true, the return type’s .scope_items method will be applied to this field’s return value



132
133
134
135
136
137
138
139
# File 'lib/graphql/schema/field.rb', line 132

def scoped?
  if !@scope.nil?
    # The default was overridden
    @scope
  else
    @return_type_expr && (@return_type_expr.is_a?(Array) || (@return_type_expr.is_a?(String) && @return_type_expr.include?("[")) || connection?)
  end
end

#to_graphqlGraphQL::Field

Returns:



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/graphql/schema/field.rb', line 330

def to_graphql
  field_defn = if @field
    @field.dup
  elsif @function
    GraphQL::Function.build_field(@function)
  else
    GraphQL::Field.new
  end

  field_defn.name = @name
  if @return_type_expr
    field_defn.type = -> { type }
  end

  if @description
    field_defn.description = @description
  end

  if @deprecation_reason
    field_defn.deprecation_reason = @deprecation_reason
  end

  if @resolver_class
    if @resolver_class < GraphQL::Schema::Mutation
      field_defn.mutation = @resolver_class
    end
    field_defn.[:resolver] = @resolver_class
  end

  if !@trace.nil?
    field_defn.trace = @trace
  end

  if @relay_node_field
    field_defn.relay_node_field = @relay_node_field
  end

  if @relay_nodes_field
    field_defn.relay_nodes_field = @relay_nodes_field
  end

  field_defn.resolve = self.method(:resolve_field)
  field_defn.connection = connection?
  field_defn.connection_max_page_size = max_page_size
  field_defn.introspection = @introspection
  field_defn.complexity = @complexity
  field_defn.subscription_scope = @subscription_scope

  arguments.each do |name, defn|
    arg_graphql = defn.to_graphql
    field_defn.arguments[arg_graphql.name] = arg_graphql
  end

  # Support a passed-in proc, one way or another
  @resolve_proc = if @resolve
    @resolve
  elsif @function
    @function
  elsif @field
    @field.resolve_proc
  end

  # Ok, `self` isn't a class, but this is for consistency with the classes
  field_defn.[:type_class] = self

  field_defn
end

#typeObject



398
399
400
401
402
# File 'lib/graphql/schema/field.rb', line 398

def type
  @type ||= Member::BuildType.parse_type(@return_type_expr, null: @return_type_null)
rescue
  raise ArgumentError, "Failed to build return type for #{@owner.graphql_name}.#{name} from #{@return_type_expr.inspect}: #{$!.message}", $!.backtrace
end

#visible?(context) ⇒ Boolean

Returns:

  • (Boolean)


404
405
406
407
408
409
410
# File 'lib/graphql/schema/field.rb', line 404

def visible?(context)
  if @resolver_class
    @resolver_class.visible?(context)
  else
    true
  end
end