graphql 0.18.9 → 0.18.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18dd53e870fcdffcb0ce92efe962848d7e9b0259
4
- data.tar.gz: edc7a7a7e56f10bbd3f50b330fe59f53efc35653
3
+ metadata.gz: e1f410073bc1513435fe5551135544b6925a01d3
4
+ data.tar.gz: a0d737582d9918e19891a00c88e3d6829f1cc1c8
5
5
  SHA512:
6
- metadata.gz: 1082187dac20710314b4dc469514f20d91f2619b6f658cf66ff8992e50813aa658eb47a0c7e0eb0d1febed8f7615cadcd7382e57dfe15b5a43e00da94f055cd1
7
- data.tar.gz: 251ff406e0738e217bcbb1a5983a6ac7e2bc4c99678417bf16aead3bfa5a31d1a04f9b225cab14bef1e514c293719ec3f046fffb265a30b42b4e112d37f51020
6
+ metadata.gz: 3beaf630fe3303784f85f3ae17ac89b427378ce5eeec8d7b6d7c76a6bfc699dc85e58ca87521a62b20e4b7c0c937411f0ce48cc1a40638e86b3b81991dea2964
7
+ data.tar.gz: 52384d58bf87b5f18fb898ce2930d91d82e537269567d3d40ab0cd31a29367355d0048d4396c6002c123ee66d8f994ff347c01e2d342ae73561bd6d04807223e
data/lib/graphql/field.rb CHANGED
@@ -120,9 +120,13 @@ module GraphQL
120
120
  #
121
121
  class Field
122
122
  include GraphQL::Define::InstanceDefinable
123
- accepts_definitions :name, :description, :resolve, :type, :property, :deprecation_reason, :complexity, :hash_key, :arguments, argument: GraphQL::Define::AssignArgument
123
+ accepts_definitions :name, :description, :deprecation_reason,
124
+ :resolve, :type, :arguments,
125
+ :property, :hash_key, :complexity, :mutation,
126
+ argument: GraphQL::Define::AssignArgument
124
127
 
125
- lazy_defined_attr_accessor :deprecation_reason, :description, :property, :hash_key
128
+
129
+ lazy_defined_attr_accessor :deprecation_reason, :description, :property, :hash_key, :mutation
126
130
 
127
131
  # @return [<#call(obj, args,ctx)>] A proc-like object which can be called to return the field's value
128
132
  attr_reader :resolve_proc
@@ -143,6 +147,9 @@ module GraphQL
143
147
 
144
148
  attr_writer :arguments
145
149
 
150
+ # @!attribute mutation
151
+ # @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation
152
+
146
153
  # @return [Numeric, Proc] The complexity for this field (default: 1), as a constant or a proc like `-> (query_ctx, args, child_complexity) { } # Numeric`
147
154
  def complexity
148
155
  ensure_defined
@@ -24,11 +24,16 @@ module GraphQL
24
24
  #
25
25
  class InputObjectType < GraphQL::BaseType
26
26
  accepts_definitions(
27
- :arguments,
27
+ :arguments, :mutation,
28
28
  input_field: GraphQL::Define::AssignArgument,
29
29
  argument: GraphQL::Define::AssignArgument
30
30
  )
31
31
 
32
+ lazy_defined_attr_accessor :mutation
33
+
34
+ # @!attribute mutation
35
+ # @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation
36
+
32
37
  # @return [Hash<String => GraphQL::Argument>] Map String argument names to their {GraphQL::Argument} implementations
33
38
  def arguments
34
39
  ensure_defined
@@ -21,10 +21,16 @@ module GraphQL
21
21
  # end
22
22
  #
23
23
  class ObjectType < GraphQL::BaseType
24
- accepts_definitions :interfaces, :fields, field: GraphQL::Define::AssignObjectField
24
+ accepts_definitions :interfaces, :fields, :mutation, field: GraphQL::Define::AssignObjectField
25
+
26
+ lazy_defined_attr_accessor :fields, :mutation
27
+
28
+ # @!attribute fields
29
+ # @return [Hash<String => GraphQL::Field>] Map String fieldnames to their {GraphQL::Field} implementations
30
+
31
+ # @!attribute mutation
32
+ # @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation
25
33
 
26
- # @return [Hash<String => GraphQL::Field>] Map String fieldnames to their {GraphQL::Field} implementations
27
- lazy_defined_attr_accessor :fields
28
34
 
29
35
  def initialize
30
36
  @fields = {}
@@ -74,16 +74,17 @@ module GraphQL
74
74
  def field
75
75
  @field ||= begin
76
76
  ensure_defined
77
- field_return_type = self.return_type
78
- field_input_type = self.input_type
77
+ relay_mutation = self
79
78
  field_resolve_proc = -> (obj, args, ctx){
80
79
  results_hash = @resolve_proc.call(args[:input], ctx)
81
80
  Result.new(arguments: args, result: results_hash)
82
81
  }
83
- GraphQL::Field.define(description: self.description) do
84
- type(field_return_type)
85
- argument :input, !field_input_type
82
+ GraphQL::Field.define do
83
+ type(relay_mutation.return_type)
84
+ description(relay_mutation.description)
85
+ argument :input, !relay_mutation.input_type
86
86
  resolve(field_resolve_proc)
87
+ mutation(relay_mutation)
87
88
  end
88
89
  end
89
90
  end
@@ -91,16 +92,15 @@ module GraphQL
91
92
  def return_type
92
93
  @return_type ||= begin
93
94
  ensure_defined
94
- mutation_name = name
95
- type_name = "#{mutation_name}Payload"
96
- type_fields = return_fields
95
+ relay_mutation = self
97
96
  GraphQL::ObjectType.define do
98
- name(type_name)
99
- description("Autogenerated return type of #{mutation_name}")
97
+ name("#{relay_mutation.name}Payload")
98
+ description("Autogenerated return type of #{relay_mutation.name}")
100
99
  field :clientMutationId, types.String, "A unique identifier for the client performing the mutation."
101
- type_fields.each do |name, field_obj|
100
+ relay_mutation.return_fields.each do |name, field_obj|
102
101
  field name, field: field_obj
103
102
  end
103
+ mutation(relay_mutation)
104
104
  end
105
105
  end
106
106
  end
@@ -108,16 +108,15 @@ module GraphQL
108
108
  def input_type
109
109
  @input_type ||= begin
110
110
  ensure_defined
111
- mutation_name = name
112
- type_name = "#{mutation_name}Input"
113
- type_fields = input_fields
111
+ relay_mutation = self
114
112
  GraphQL::InputObjectType.define do
115
- name(type_name)
116
- description("Autogenerated input type of #{mutation_name}")
113
+ name("#{relay_mutation.name}Input")
114
+ description("Autogenerated input type of #{relay_mutation.name}")
117
115
  input_field :clientMutationId, types.String, "A unique identifier for the client performing the mutation."
118
- type_fields.each do |name, field_obj|
119
- input_field name, field_obj.type, field_obj.description, default_value: field_obj.default_value
116
+ relay_mutation.input_fields.each do |input_field_name, field_obj|
117
+ input_field input_field_name, field_obj.type, field_obj.description, default_value: field_obj.default_value
120
118
  end
119
+ mutation(relay_mutation)
121
120
  end
122
121
  end
123
122
  end
@@ -1,3 +1,3 @@
1
1
  module GraphQL
2
- VERSION = "0.18.9"
2
+ VERSION = "0.18.10"
3
3
  end
@@ -51,4 +51,10 @@ describe GraphQL::Relay::Mutation do
51
51
  it "applies the description to the derived field" do
52
52
  assert_equal "Add a ship to this faction", IntroduceShipMutation.field.description
53
53
  end
54
+
55
+ it "inserts itself into the derived objects' metadata" do
56
+ assert_equal IntroduceShipMutation, IntroduceShipMutation.field.mutation
57
+ assert_equal IntroduceShipMutation, IntroduceShipMutation.return_type.mutation
58
+ assert_equal IntroduceShipMutation, IntroduceShipMutation.input_type.mutation
59
+ end
54
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.9
4
+ version: 0.18.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter