module GraphQL::Types::Relay::EdgeBehaviors::ClassMethods

Public Instance Methods

accessible?(ctx) click to toggle source
# File lib/graphql/types/relay/edge_behaviors.rb, line 43
def accessible?(ctx)
  node_type.accessible?(ctx)
end
authorized?(obj, ctx) click to toggle source
# File lib/graphql/types/relay/edge_behaviors.rb, line 39
def authorized?(obj, ctx)
  true
end
node_nullable(new_value = nil) click to toggle source

Set the default ‘node_nullable` for this class and its child classes. (Defaults to `true`.) Use `node_nullable(false)` in your base class to make non-null `node` field.

# File lib/graphql/types/relay/edge_behaviors.rb, line 53
def node_nullable(new_value = nil)
  if new_value.nil?
    defined?(@node_nullable) ? @node_nullable : superclass.node_nullable
  else
    @node_nullable = new_value
  end
end
node_type(node_type = nil, null: self.node_nullable, field_options: nil) click to toggle source

Get or set the Object type that this edge wraps.

@param node_type [Class] A ‘Schema::Object` subclass @param null [Boolean] @param field_options [Hash] Any extra arguments to pass to the `field :node` configuration

# File lib/graphql/types/relay/edge_behaviors.rb, line 20
def node_type(node_type = nil, null: self.node_nullable, field_options: nil)
  if node_type
    @node_type = node_type
    # Add a default `node` field
    base_field_options = {
      name: :node,
      type: node_type,
      null: null,
      description: "The item at the end of the edge.",
      connection: false,
    }
    if field_options
      base_field_options.merge!(field_options)
    end
    field(**base_field_options)
  end
  @node_type
end
visible?(ctx) click to toggle source
# File lib/graphql/types/relay/edge_behaviors.rb, line 47
def visible?(ctx)
  node_type.visible?(ctx)
end