Class: GraphqlMigrateExecution::FieldDefinition
- Inherits:
-
Object
- Object
- GraphqlMigrateExecution::FieldDefinition
- Defined in:
- lib/graphql_migrate_execution/field_definition.rb
Instance Attribute Summary collapse
-
#already_migrated ⇒ Object
Returns the value of attribute already_migrated.
-
#dig ⇒ Object
Returns the value of attribute dig.
-
#fallback_value ⇒ Object
Returns the value of attribute fallback_value.
-
#hash_key ⇒ Object
Returns the value of attribute hash_key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#object_direct_method ⇒ Object
Returns the value of attribute object_direct_method.
-
#resolve_mode ⇒ Object
Returns the value of attribute resolve_mode.
-
#resolver ⇒ Object
Returns the value of attribute resolver.
-
#type_definition ⇒ Object
readonly
Returns the value of attribute type_definition.
-
#type_instance_method ⇒ Object
Returns the value of attribute type_instance_method.
-
#unknown_options ⇒ Object
readonly
Returns the value of attribute unknown_options.
Instance Method Summary collapse
- #check_for_resolver_method ⇒ Object
- #future_resolve_shorthand ⇒ Object
- #implicit_resolve ⇒ Object
-
#initialize(type_definition, name, node) ⇒ FieldDefinition
constructor
A new instance of FieldDefinition.
- #migration_strategy ⇒ Object
- #path ⇒ Object
- #resolve_mode_key ⇒ Object
- #resolver_method ⇒ Object
- #source ⇒ Object
- #source_line ⇒ Object
Constructor Details
#initialize(type_definition, name, node) ⇒ FieldDefinition
Returns a new instance of FieldDefinition.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 4 def initialize(type_definition, name, node) @type_definition = type_definition @name = name.to_sym @node = node @resolve_mode = nil @hash_key = nil @resolver = nil @type_instance_method = nil @object_direct_method = nil @dig = nil @fallback_value = nil @already_migrated = nil @resolver_method = nil @unknown_options = [] end |
Instance Attribute Details
#already_migrated ⇒ Object
Returns the value of attribute already_migrated.
79 80 81 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 79 def already_migrated @already_migrated end |
#dig ⇒ Object
Returns the value of attribute dig.
79 80 81 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 79 def dig @dig end |
#fallback_value ⇒ Object
Returns the value of attribute fallback_value.
79 80 81 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 79 def fallback_value @fallback_value end |
#hash_key ⇒ Object
Returns the value of attribute hash_key.
79 80 81 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 79 def hash_key @hash_key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
66 67 68 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 66 def name @name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
66 67 68 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 66 def node @node end |
#object_direct_method ⇒ Object
Returns the value of attribute object_direct_method.
79 80 81 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 79 def object_direct_method @object_direct_method end |
#resolve_mode ⇒ Object
Returns the value of attribute resolve_mode.
66 67 68 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 66 def resolve_mode @resolve_mode end |
#resolver ⇒ Object
Returns the value of attribute resolver.
79 80 81 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 79 def resolver @resolver end |
#type_definition ⇒ Object (readonly)
Returns the value of attribute type_definition.
66 67 68 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 66 def type_definition @type_definition end |
#type_instance_method ⇒ Object
Returns the value of attribute type_instance_method.
79 80 81 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 79 def type_instance_method @type_instance_method end |
#unknown_options ⇒ Object (readonly)
Returns the value of attribute unknown_options.
66 67 68 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 66 def @unknown_options end |
Instance Method Details
#check_for_resolver_method ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 110 def check_for_resolver_method if resolve_mode.nil? && (resolver_method) @resolve_mode = :type_instance_method @type_instance_method = @name end nil end |
#future_resolve_shorthand ⇒ Object
72 73 74 75 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 72 def future_resolve_shorthand method_name = Strategy.prefix_if_necessary(resolver_method.name).to_sym name == method_name ? true : method_name end |
#implicit_resolve ⇒ Object
102 103 104 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 102 def implicit_resolve @name end |
#migration_strategy ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 22 def migration_strategy if unsupported_extras? return UnsupportedExtra elsif resolver_method&.uses_current_path return UnsupportedCurrentPath end if @type_definition.is_resolver && @type_definition.returns_hash? return HashKey end case resolve_mode when nil, :implicit_resolve if @type_definition.migration.implicit == "ignore" DoNothing else Implicit end when :hash_key, :object_direct_method, :dig DoNothing when :already_migrated case @already_migrated.keys.first when :resolve_each ResolveEach when :resolve_static ResolveStatic when :resolve_batch ResolveBatch when :resolve_legacy_instance_method DoNothing else raise ArgumentError, "Unexpected already_migrated: #{@already_migrated.inspect}" end when :type_instance_method resolver_method.migration_strategy when :resolver DoNothing when :fallback_value FallbackValue else raise "No migration strategy for resolve_mode #{@resolve_mode.inspect}" end end |
#path ⇒ Object
81 82 83 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 81 def path @path ||= "#{type_definition.name}.#{@name}" end |
#resolve_mode_key ⇒ Object
106 107 108 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 106 def resolve_mode_key resolve_mode && public_send(resolve_mode) end |
#resolver_method ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 89 def resolver_method case @resolver_method when nil method_name = @type_instance_method || @name @resolver_method = @type_definition.resolver_methods[method_name] || :NOT_FOUND resolver_method when :NOT_FOUND nil else @resolver_method end end |
#source ⇒ Object
68 69 70 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 68 def source node.location.slice end |
#source_line ⇒ Object
85 86 87 |
# File 'lib/graphql_migrate_execution/field_definition.rb', line 85 def source_line @node.location.start_line end |