Skip to content

Commit fad460d

Browse files
jrichardlairmosolgo
authored andcommitted
error: prepared input types breaks FieldUsage
1 parent ec1ae00 commit fad460d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

spec/graphql/analysis/ast/field_usage_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@
254254
end
255255
end
256256

257+
describe "mutation with deprecated arguments with prepared values" do
258+
let(:query_string) {%|
259+
mutation {
260+
pushValue(preparedTestInput: { deprecatedDate: "2020-10-10" })
261+
}
262+
|}
263+
264+
it "keeps track of nested deprecated arguments" do
265+
assert_equal ['PreparedDateInput.deprecatedDate'], result[:used_deprecated_arguments]
266+
end
267+
end
257268

258269
describe "when an argument prepare raises a GraphQL::ExecutionError" do
259270
class ArgumentErrorFieldUsageSchema < GraphQL::Schema

spec/support/dummy/schema.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ class DairyProductInput < BaseInputObject
265265
argument :old_source, String, required: false, deprecation_reason: "No longer supported"
266266
end
267267

268+
class PreparedDateInput < BaseInputObject
269+
description "Input with prepared value"
270+
argument :date, String, description: "date as a string", required: false
271+
argument :deprecated_date, String, description: "date as a string", required: false, deprecation_reason: "Use date"
272+
273+
def prepare
274+
return nil unless date || deprecated_date
275+
276+
Date.parse(date || deprecated_date)
277+
end
278+
end
279+
268280
class DeepNonNull < BaseObject
269281
field :non_null_int, Integer, null: false do
270282
argument :returning, Integer, required: false
@@ -492,6 +504,7 @@ class DairyAppMutation < BaseObject
492504
field :push_value, [Integer], null: false, description: "Push a value onto a global array :D" do
493505
argument :value, Integer, as: :val
494506
argument :deprecated_test_input, DairyProductInput, required: false
507+
argument :prepared_test_input, PreparedDateInput, required: false
495508
end
496509
def push_value(val:)
497510
GLOBAL_VALUES << val

0 commit comments

Comments
 (0)