Module: GraphQL::Schema::Member::BaseDSLMethods Private

Includes:
FindInheritedValue
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.

See Also:

  • that extend this, eg {GraphQL::Schema::Object}

Defined Under Namespace

Modules: ConfigurationExtension

Instance Method Summary collapse

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.

Returns:



123
124
125
126
127
128
129
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 123

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.

Returns:



131
132
133
134
135
136
137
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 131

def authorized?(object, context)
  if @mutation
    @mutation.authorized?(object, context)
  else
    true
  end
end

#default_graphql_nameObject

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



107
108
109
110
111
112
113
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 107

def default_graphql_name
  @default_graphql_name ||= begin
    raise GraphQL::RequiredImplementationMissingError, '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

Parameters:

  • new_description (String) (defaults to: nil)

Returns:

  • (String)


47
48
49
50
51
52
53
54
55
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 47

def description(new_description = nil)
  if new_description
    @description = new_description
  elsif defined?(@description)
    @description
  else
    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

Parameters:

  • new_name (String) (defaults to: nil)

Returns:

  • (String)


20
21
22
23
24
25
26
27
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 20

def graphql_name(new_name = nil)
  if new_name
    GraphQL::NameValidator.validate!(new_name)
    @graphql_name = new_name
  else
    overridden_graphql_name || 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.

Returns:

  • (Boolean)

    If true, this object is part of the introspection system



71
72
73
74
75
76
77
78
79
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 71

def introspection(new_introspection = nil)
  if !new_introspection.nil?
    @introspection = new_introspection
  elsif defined?(@introspection)
    @introspection
  else
    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.

Returns:



81
82
83
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 81

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

Returns:

  • (Class)


87
88
89
90
91
92
93
94
95
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 87

def mutation(mutation_class = nil)
  if mutation_class
    @mutation = mutation_class
  elsif defined?(@mutation)
    @mutation
  else
    nil
  end
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



34
35
36
37
38
39
40
41
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 34

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_nameObject

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.



29
30
31
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 29

def overridden_graphql_name
  defined?(@graphql_name) ? @graphql_name : nil
end

#to_graphqlGraphQL::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.

Returns:

Raises:



98
99
100
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 98

def to_graphql
  raise GraphQL::RequiredImplementationMissingError
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.

Returns:



115
116
117
118
119
120
121
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 115

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