Module: GraphQL::Schema::Member::BaseDSLMethods
- Includes:
- FindInheritedValue
- Included in:
- Interface::DefinitionMethods, GraphQL::Schema::Member, Resolver
- Defined in:
- lib/graphql/schema/member/base_dsl_methods.rb
Overview
DSL methods shared by lots of things in the GraphQL Schema. See classes that extend this, eg GraphQL::Schema::Object
@requires_ancestor: Kernel @requires_ancestor: Module
Defined Under Namespace
Modules: ConfigurationExtension
Instance Attribute Summary collapse
-
#default_graphql_name ⇒ Object
readonly
Creates the default name for a schema member.
-
#graphql_name(new_name = nil) ⇒ Object
readonly
Call this with a new name to override the default name for this schema member; OR call it without an argument to get the name of this schema member.
Instance Method Summary collapse
- #authorized?(object, context) ⇒ Boolean
-
#comment(new_comment = NOT_CONFIGURED) ⇒ Object
Call this method to provide a new comment; OR call it without an argument to get the comment.
- #default_relay? ⇒ Boolean
-
#description(new_description = nil) ⇒ Object
Call this method to provide a new description; OR call it without an argument to get the description.
-
#introspection(new_introspection = nil) ⇒ Object
Returns.
- #introspection? ⇒ Boolean
-
#mutation(mutation_class = nil) ⇒ Object
The mutation this type was derived from, if it was derived from a mutation.
- #visible?(context) ⇒ Boolean
Methods included from FindInheritedValue
Instance Attribute Details
#default_graphql_name ⇒ Object
Creates the default name for a schema member.
The default name is the Ruby constant name,
without any namespaces and with any -Type suffix removed
152 153 154 155 156 157 158 159 160 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 152 def default_graphql_name @default_graphql_name ||= begin raise GraphQL::RequiredImplementationMissingError, 'Anonymous class should declare a `graphql_name`' if name.nil? class_name = name #: as !nil short_name = class_name.split("::").last #: as String g_name = -short_name g_name.end_with?("Type") ? g_name.sub(/Type\Z/, "") : g_name end end |
#graphql_name(new_name = nil) ⇒ Object
Call this with a new name to override the default name for this schema member; OR call it without an argument to get the name of this schema member
The default name is implemented in default_graphql_name
Parameters
new_name(String)
Returns
String
:call-seq:
graphql_name(String new_name) -> String
33 34 35 36 37 38 39 40 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 33 def graphql_name(new_name = nil) if new_name GraphQL::NameValidator.validate!(new_name) @graphql_name = new_name else @graphql_name ||= default_graphql_name end end |
Instance Method Details
#authorized?(object, context) ⇒ Boolean
166 167 168 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 166 def (object, context) true end |
#comment(new_comment = NOT_CONFIGURED) ⇒ Object
Call this method to provide a new comment; OR call it without an argument to get the comment
Parameters
new_comment(String)
Returns
String, nil
:call-seq:
comment(String new_comment) -> String | nil
78 79 80 81 82 83 84 85 86 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 78 def comment(new_comment = NOT_CONFIGURED) if !NOT_CONFIGURED.equal?(new_comment) @comment = new_comment elsif defined?(@comment) @comment else nil end end |
#default_relay? ⇒ Boolean
170 171 172 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 170 def default_relay? false end |
#description(new_description = nil) ⇒ Object
Call this method to provide a new description; OR call it without an argument to get the description
Parameters
new_description(String)
Returns
String
:call-seq:
description(String new_description) -> String
55 56 57 58 59 60 61 62 63 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 55 def description(new_description = nil) if new_description @description = new_description elsif defined?(@description) @description else @description = nil end end |
#introspection(new_introspection = nil) ⇒ Object
Returns
Boolean— If true, this object is part of the introspection system
:call-seq:
introspection(new_introspection) -> bool
115 116 117 118 119 120 121 122 123 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 115 def introspection(new_introspection = nil) if !new_introspection.nil? @introspection = new_introspection elsif defined?(@introspection) @introspection else false end end |
#introspection? ⇒ Boolean
125 126 127 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 125 def introspection? !!@introspection end |
#mutation(mutation_class = nil) ⇒ Object
The mutation this type was derived from, if it was derived from a mutation
Returns
Class
:call-seq:
mutation(mutation_class) -> Class
137 138 139 140 141 142 143 144 145 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 137 def mutation(mutation_class = nil) if mutation_class @mutation = mutation_class elsif defined?(@mutation) @mutation else nil end end |
#visible?(context) ⇒ Boolean
162 163 164 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 162 def visible?(context) true end |