Module: GraphQL::Types::Relay::EdgeBehaviors::ClassMethods
- Defined in:
- lib/graphql/types/relay/edge_behaviors.rb
Instance Attribute Summary collapse
-
#node_nullable(new_value = nil) ⇒ Object
readonly
Set the default
node_nullablefor this class and its child classes. -
#node_type(node_type = nil, null: self.node_nullable, field_options: nil) ⇒ Object
readonly
Get or set the Object type that this edge wraps.
Instance Method Summary collapse
-
#authorized?(obj, ctx) ⇒ Boolean
-
#default_broadcastable(new_value) ⇒ Object
-
#default_broadcastable? ⇒ Boolean
-
#default_relay? ⇒ Boolean
-
#inherited(child_class) ⇒ Object
-
#visible?(ctx) ⇒ Boolean
Instance Attribute Details
#node_nullable(new_value = nil) ⇒ Object
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.
78 79 80 81 82 83 84 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 78 def node_nullable(new_value = nil) if new_value.nil? @node_nullable != nil ? @node_nullable : superclass.node_nullable else @node_nullable = new_value end end |
#node_type(node_type = nil, null: self.node_nullable, field_options: nil) ⇒ Object
Get or set the Object type that this edge wraps.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 49 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 = { name: :node, type: node_type, null: null, description: "The item at the end of the edge.", connection: false, } if .merge!() end field(**) end @node_type end |
Instance Method Details
#authorized?(obj, ctx) ⇒ Boolean
68 69 70 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 68 def (obj, ctx) true end |
#default_broadcastable(new_value) ⇒ Object
40 41 42 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 40 def default_broadcastable(new_value) @default_broadcastable = new_value end |
#default_broadcastable? ⇒ Boolean
36 37 38 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 36 def default_broadcastable? @default_broadcastable end |
#default_relay? ⇒ Boolean
32 33 34 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 32 def default_relay? true end |
#inherited(child_class) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 25 def inherited(child_class) super child_class.node_type = nil child_class.node_nullable = nil child_class.default_broadcastable(default_broadcastable?) end |
#visible?(ctx) ⇒ Boolean
72 73 74 |
# File 'lib/graphql/types/relay/edge_behaviors.rb', line 72 def visible?(ctx) node_type.visible?(ctx) end |