module GraphQL::Schema::Member::BaseDSLMethods

DSL methods shared by lots of things in the GraphQL Schema. @api private @see Classes that extend this, eg {GraphQL::Schema::Object}

Public Instance Methods

accessible?(context) click to toggle source
# File lib/graphql/schema/member/base_dsl_methods.rb, line 114
def accessible?(context)
  true
end
authorized?(object, context) click to toggle source
# File lib/graphql/schema/member/base_dsl_methods.rb, line 118
def authorized?(object, context)
  true
end
default_graphql_name() click to toggle source

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

# File lib/graphql/schema/member/base_dsl_methods.rb, line 102
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) click to toggle source

Call this method to provide a new description; OR call it without an argument to get the description @param new_description [String] @return [String]

# 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) click to toggle source

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 @param new_name [String] @return [String]

# 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) click to toggle source

@return [Boolean] If true, this object is part of the introspection system

# 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?() click to toggle source
# File lib/graphql/schema/member/base_dsl_methods.rb, line 81
def introspection?
  introspection
end
mutation(mutation_class = nil) click to toggle source

The mutation this type was derived from, if it was derived from a mutation @return [Class]

# 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) click to toggle source

Just a convenience method to point out that people should use graphql_name instead

Calls superclass method
# 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_name() click to toggle source
# File lib/graphql/schema/member/base_dsl_methods.rb, line 29
def overridden_graphql_name
  defined?(@graphql_name) ? @graphql_name : nil
end
visible?(context) click to toggle source
# File lib/graphql/schema/member/base_dsl_methods.rb, line 110
def visible?(context)
  true
end