Module: GraphQL::Schema::Member::BaseDSLMethods Private
- Included in:
- Interface::DefinitionMethods, GraphQL::Schema::Member, Resolver
- Defined in:
- lib/graphql/schema/member/base_dsl_methods.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
DSL methods shared by lots of things in the GraphQL Schema.
Instance Method Summary collapse
-
#accessible?(context) ⇒ Boolean
private
-
#authorized?(object, context) ⇒ Boolean
private
-
#default_graphql_name ⇒ Object
private
Creates the default name for a schema member.
-
#description(new_description = nil) ⇒ String
private
Call this method to provide a new description; OR call it without an argument to get the description.
-
#graphql_name(new_name = nil) ⇒ String
private
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.
-
#introspection(new_introspection = nil) ⇒ Boolean
private
If true, this object is part of the introspection system.
-
#introspection? ⇒ Boolean
private
-
#mutation(mutation_class = nil) ⇒ Class
private
The mutation this type was derived from, if it was derived from a mutation.
-
#name(new_name = nil) ⇒ Object
private
Just a convenience method to point out that people should use graphql_name instead.
-
#overridden_graphql_name ⇒ Object
private
-
#to_graphql ⇒ GraphQL::BaseType
private
Convert this type to a legacy-style object.
-
#visible?(context) ⇒ Boolean
private
Instance Method Details
#accessible?(context) ⇒ Boolean
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.
101 102 103 104 105 106 107 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 101 def accessible?(context) if @mutation @mutation.accessible?(context) else true end end |
#authorized?(object, context) ⇒ Boolean
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.
109 110 111 112 113 114 115 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 109 def (object, context) if @mutation @mutation.(object, context) else true end end |
#default_graphql_name ⇒ 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.
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
85 86 87 88 89 90 91 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 85 def default_graphql_name @default_graphql_name ||= begin raise NotImplementedError, 'Anonymous class should declare a `graphql_name`' if name.nil? name.split("::").last.sub(/Type\Z/, "") end end |
#description(new_description = nil) ⇒ String
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.
Call this method to provide a new description; OR call it without an argument to get the description
41 42 43 44 45 46 47 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 41 def description(new_description = nil) if new_description @description = new_description else @description || find_inherited_method(:description, nil) end end |
#graphql_name(new_name = nil) ⇒ String
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.
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
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 16 def graphql_name(new_name = nil) case when new_name @graphql_name = new_name when overridden = overridden_graphql_name overridden else default_graphql_name end end |
#introspection(new_introspection = nil) ⇒ Boolean
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 If true, this object is part of the introspection system
50 51 52 53 54 55 56 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 50 def introspection(new_introspection = nil) if !new_introspection.nil? @introspection = new_introspection else @introspection || find_inherited_method(:introspection, false) end end |
#introspection? ⇒ Boolean
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.
58 59 60 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 58 def introspection? introspection end |
#mutation(mutation_class = nil) ⇒ Class
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.
The mutation this type was derived from, if it was derived from a mutation
64 65 66 67 68 69 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 64 def mutation(mutation_class = nil) if mutation_class @mutation = mutation_class end @mutation end |
#name(new_name = nil) ⇒ 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.
Just a convenience method to point out that people should use graphql_name instead
28 29 30 31 32 33 34 35 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 28 def name(new_name = nil) return super() if new_name.nil? fail( "The new name override method is `graphql_name`, not `name`. Usage: "\ "graphql_name \"#{new_name}\"" ) end |
#overridden_graphql_name ⇒ 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.
78 79 80 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 78 def overridden_graphql_name @graphql_name || find_inherited_method(:overridden_graphql_name, nil) end |
#to_graphql ⇒ GraphQL::BaseType
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 Convert this type to a legacy-style object.
72 73 74 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 72 def to_graphql raise NotImplementedError end |
#visible?(context) ⇒ Boolean
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.
93 94 95 96 97 98 99 |
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 93 def visible?(context) if @mutation @mutation.visible?(context) else true end end |