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.

See Also:

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

Instance Method Summary collapse

Instance Method Details

#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)


44
45
46
47
48
49
50
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 44

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 the Ruby constant name, without any namespaces and with any -Type suffix removed

Parameters:

  • new_name (String) (defaults to: nil)

Returns:

  • (String)


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

def graphql_name(new_name = nil)
  case
  when new_name
    @graphql_name = new_name
  when overridden = overridden_graphql_name
    overridden
  else # Fallback to Ruby constant name
    raise NotImplementedError, 'Anonymous class should declare an `graphql_name`' if name.nil?
    
    name.split("::").last.sub(/Type\Z/, "")
  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



53
54
55
56
57
58
59
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 53

def introspection(new_introspection = nil)
  if !new_introspection.nil?
    @introspection = new_introspection
  else
    @introspection || find_inherited_method(:introspection, false)
  end
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)


63
64
65
66
67
68
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 63

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



31
32
33
34
35
36
37
38
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 31

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.



75
76
77
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 75

def overridden_graphql_name
  @graphql_name || find_inherited_method(:overridden_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:

  • (NotImplementedError)


71
72
73
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 71

def to_graphql
  raise NotImplementedError
end

#unwrapObject

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.



79
80
81
# File 'lib/graphql/schema/member/base_dsl_methods.rb', line 79

def unwrap
  self
end