Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL::Analysis::AST::FieldUsage does not detect deprecated arguments inside mutation input objects #4805

Closed
lukes opened this issue Jan 23, 2024 · 2 comments

Comments

@lukes
Copy link
Contributor

lukes commented Jan 23, 2024

Describe the bug

GraphQL::Analysis::AST::FieldUsage has support for detecting deprecated arguments inside an input object however it only works for queries and not mutations. On that line with a mutation argument.definition.type.kind is a GraphQL::TypeKinds::TypeKind.

Versions

graphql version: 2.2.5

Steps to reproduce

This patched spec fails:

diff --git a/spec/graphql/analysis/ast/field_usage_spec.rb b/spec/graphql/analysis/ast/field_usage_spec.rb
index 9fc68e38d..e95a6a1b9 100644
--- a/spec/graphql/analysis/ast/field_usage_spec.rb
+++ b/spec/graphql/analysis/ast/field_usage_spec.rb
@@ -225,6 +225,18 @@ describe GraphQL::Analysis::AST::FieldUsage do
     end
   end

+  describe "mutation with deprecated argument" do
+    let(:query_string) {%|
+      mutation {
+        pushValue(input: { oldSource: "deprecated" })
+      }
+    |}
+
+    it "keeps track of nested deprecated arguments" do
+      assert_equal ['Mutation.input.oldSource'], result[:used_deprecated_arguments]
+    end
+  end
+
   describe "when an argument prepare raises a GraphQL::ExecutionError" do
     class ArgumentErrorFieldUsageSchema < GraphQL::Schema
       class FieldUsage < GraphQL::Analysis::AST::FieldUsage
diff --git a/spec/support/dummy/schema.rb b/spec/support/dummy/schema.rb
index f159f4ffd..4435f578d 100644
--- a/spec/support/dummy/schema.rb
+++ b/spec/support/dummy/schema.rb
@@ -489,6 +489,7 @@ module Dummy
     description "The root for mutations in this schema"
     field :push_value, [Integer], null: false, description: "Push a value onto a global array :D" do
       argument :value, Integer, as: :val
+      argument :input, DairyProductInput
     end
     def push_value(val:)
       GLOBAL_VALUES << val

Expected behavior

GraphQL::Analysis::AST::FieldUsage can detect deprecated arguments within input objects in a mutation.

Actual behavior

GraphQL::Analysis::AST::FieldUsage can only detect deprecated arguments within input objects in a query, but not a mutation.

@rmosolgo
Copy link
Owner

Hey, thanks for the detailed report! I agree it should cover that case too. I wonder why it's not finding them ...

@rmosolgo
Copy link
Owner

Fixed by #4804

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants