Module: GraphQL::Decorate

Extended by:
ExtractType
Defined in:
lib/graphql/decorate.rb,
lib/graphql/decorate/version.rb,
lib/graphql/decorate/metadata.rb,
lib/graphql/decorate/decoration.rb,
lib/graphql/decorate/configuration.rb,
lib/graphql/decorate/field_extension.rb,
lib/graphql/decorate/type_attributes.rb,
lib/graphql/decorate/undecorated_field.rb,
lib/graphql/decorate/object_integration.rb

Overview

Entry point for graphql-decorate. Handles configuration.

Defined Under Namespace

Modules: ObjectIntegration Classes: Configuration, Decoration, FieldExtension, Metadata, TypeAttributes, UndecoratedField

Constant Summary collapse

VERSION =

Current version number

'1.0.4'

Class Method Summary collapse

Class Method Details

.configurationConfiguration

Returns a new instance of GraphQL::Decorate::Configuration.

Returns:

  • (Configuration)

    Returns a new instance of GraphQL::Decorate::Configuration.



21
22
23
# File 'lib/graphql/decorate.rb', line 21

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



26
27
28
# File 'lib/graphql/decorate.rb', line 26

def self.configure
  yield(configuration)
end

.reset_configuration!Configuration

Returns Resets the configuration to its defaults.

Returns:



31
32
33
# File 'lib/graphql/decorate.rb', line 31

def self.reset_configuration!
  @configuration = Configuration.new
end

.use(schema_defn) ⇒ nil

Parameters:

  • schema_defn (GraphQL::Schema)

    Current schema class

Returns:

  • (nil)


37
38
39
40
41
42
43
44
45
46
47
# File 'lib/graphql/decorate.rb', line 37

def self.use(schema_defn)
  schema_defn.types.each do |_name, type|
    next unless type.respond_to?(:fields)

    type.fields.each do |_name, field|
      field_type = extract_type(field.type)
      type_attributes = GraphQL::Decorate::TypeAttributes.new(field_type)
      field.extension(GraphQL::Decorate::FieldExtension) if type_attributes.decoratable?
    end
  end
end