Skip to content

Commit a57a7c4

Browse files
committed
Fix some merges
1 parent a4b2b67 commit a57a7c4

File tree

2 files changed

+40
-36
lines changed

2 files changed

+40
-36
lines changed

spec/graphql/authorization_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def authorized?(parent_object, value, context)
2424
end
2525
end
2626

27-
<<<<<<< HEAD
2827
class BaseInputObjectArgument < BaseArgument
2928
def authorized?(parent_object, value, context)
3029
super && parent_object != :hide3
@@ -35,8 +34,6 @@ class BaseInputObject < GraphQL::Schema::InputObject
3534
argument_class BaseInputObjectArgument
3635
end
3736

38-
=======
39-
>>>>>>> Revert "Authorize arguments of input objects, too"
4037
class BaseField < GraphQL::Schema::Field
4138
def initialize(*args, edge_class: nil, **kwargs, &block)
4239
@edge_class = edge_class

spec/graphql/schema/input_object_spec.rb

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,8 @@
6161
end
6262
end
6363

64-
<<<<<<< HEAD
6564
describe "prepare: / loads: / as:" do
6665
module InputObjectPrepareTest
67-
=======
68-
describe "prepare: / as: (argument)" do
69-
module InputObjectPrepareArgumentTest
70-
>>>>>>> Prepare input objects
7166
class InputObj < GraphQL::Schema::InputObject
7267
argument :a, Integer, required: true
7368
argument :b, Integer, required: true, as: :b2
@@ -140,13 +135,8 @@ def self.resolve_type(type, obj, ctx)
140135
{ inputs(input: { a: 1, b: 2, c: 3, d: 4, e: 5, instrumentId: "Instrument/Drum Kit" }) }
141136
GRAPHQL
142137

143-
<<<<<<< HEAD
144138
res = InputObjectPrepareTest::Schema.execute(query_str, context: { multiply_by: 3 })
145139
expected_obj = [{ a: 1, b2: 2, c: 9, d2: 12, e2: 30, instrument: Jazz::Models::Instrument.new("Drum Kit", "PERCUSSION") }.inspect, "Drum Kit"]
146-
=======
147-
res = InputObjectPrepareArgumentTest::Schema.execute(query_str, context: { multiply_by: 3 })
148-
expected_obj = { a: 1, b2: 2, c: 9, d2: 12, e2: 30 }.inspect
149-
>>>>>>> Prepare input objects
150140
assert_equal expected_obj, res["data"]["inputs"]
151141
end
152142

@@ -181,33 +171,31 @@ def self.resolve_type(type, obj, ctx)
181171
end
182172
end
183173

184-
describe "loading application object(s)" do
185-
module InputObjectLoadsTest
186-
class BaseArgument < GraphQL::Schema::Argument
187-
def authorized?(obj, val, ctx)
188-
if contains_spinal_tap?(val)
189-
false
190-
else
191-
true
192-
end
174+
describe "prepare (entire input object)" do
175+
module InputObjectPrepareObjectTest
176+
class InputObj < GraphQL::Schema::InputObject
177+
argument :min, Integer, required: true
178+
argument :max, Integer, required: false
179+
180+
def prepare
181+
min..max
193182
end
183+
end
194184

195-
def contains_spinal_tap?(val)
196-
if val.is_a?(Array)
197-
val.any? { |v| contains_spinal_tap?(v) }
198-
else
199-
val.is_a?(Jazz::Models::Ensemble) && val.name == "Spinal Tap"
200-
end
185+
class Query < GraphQL::Schema::Object
186+
field :inputs, String, null: false do
187+
argument :input, InputObj, required: true
188+
end
189+
190+
def inputs(input:)
191+
input.inspect
201192
end
202193
end
203194

204-
<<<<<<< HEAD
205-
=======
206195
class Schema < GraphQL::Schema
207196
query(Query)
208197

209198
if TESTING_INTERPRETER
210-
use GraphQL::Analysis::AST
211199
use GraphQL::Execution::Interpreter
212200
end
213201
end
@@ -234,9 +222,27 @@ class Schema < GraphQL::Schema
234222
end
235223
end
236224

225+
237226
describe "loading application object(s)" do
238227
module InputObjectLoadsTest
239-
>>>>>>> initial debug
228+
class BaseArgument < GraphQL::Schema::Argument
229+
def authorized?(obj, val, ctx)
230+
if contains_spinal_tap?(val)
231+
false
232+
else
233+
true
234+
end
235+
end
236+
237+
def contains_spinal_tap?(val)
238+
if val.is_a?(Array)
239+
val.any? { |v| contains_spinal_tap?(v) }
240+
else
241+
val.is_a?(Jazz::Models::Ensemble) && val.name == "Spinal Tap"
242+
end
243+
end
244+
end
245+
240246
class SingleLoadInputObj < GraphQL::Schema::InputObject
241247
argument_class BaseArgument
242248
argument :instrument_id, ID, required: true, loads: Jazz::InstrumentType
@@ -266,10 +272,6 @@ def multi_load_input(input:)
266272

267273
class Schema < GraphQL::Schema
268274
query(Query)
269-
if TESTING_INTERPRETER
270-
use GraphQL::Execution::Interpreter
271-
use GraphQL::Analysis::AST
272-
end
273275

274276
def self.object_from_id(id, ctx)
275277
Jazz::GloballyIdentifiableType.find(id)
@@ -278,6 +280,11 @@ def self.object_from_id(id, ctx)
278280
def self.resolve_type(type, obj, ctx)
279281
type
280282
end
283+
284+
if TESTING_INTERPRETER
285+
use GraphQL::Analysis::AST
286+
use GraphQL::Execution::Interpreter
287+
end
281288
end
282289
end
283290

0 commit comments

Comments
 (0)