From 271c4340d45c6010389307524a5fb8d376acc10f Mon Sep 17 00:00:00 2001 From: Aaron Renner Date: Tue, 29 Oct 2024 14:08:58 -0600 Subject: [PATCH] Include deprecated directive args --- priv/graphql/introspection.graphql | 2 +- test/mix/tasks/absinthe.schema.json_test.exs | 33 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/priv/graphql/introspection.graphql b/priv/graphql/introspection.graphql index c1088e4afd..763678e570 100644 --- a/priv/graphql/introspection.graphql +++ b/priv/graphql/introspection.graphql @@ -18,7 +18,7 @@ query IntrospectionQuery { description locations isRepeatable - args { + args(includeDeprecated: true) { ...InputValue } } diff --git a/test/mix/tasks/absinthe.schema.json_test.exs b/test/mix/tasks/absinthe.schema.json_test.exs index 163c1aec5e..502e7fc4b4 100644 --- a/test/mix/tasks/absinthe.schema.json_test.exs +++ b/test/mix/tasks/absinthe.schema.json_test.exs @@ -10,6 +10,20 @@ defmodule Mix.Tasks.Absinthe.Schema.JsonTest do field :item, :item end + directive :mydirective do + arg :if, non_null(:boolean), description: "Skipped when true." + arg :unless, non_null(:boolean), description: "Skipped when false.", deprecate: "Use if" + on [:field, :fragment_spread, :inline_fragment] + + expand fn + %{if: true}, node -> + Absinthe.Blueprint.put_flag(node, :skip, __MODULE__) + + _, node -> + node + end + end + mutation do field :update_item, type: :item, @@ -164,6 +178,25 @@ defmodule Mix.Tasks.Absinthe.Schema.JsonTest do assert "id" in update_item_arg_names assert "item" in update_item_arg_names + + # Includes deprecated directive args by default + my_directive_arg_names = + get_in( + decoded_schema, + [ + "data", + "__schema", + "directives", + Access.filter(&(&1["name"] == "mydirective")), + "args", + Access.all(), + "name" + ] + ) + |> List.flatten() + + assert "if" in my_directive_arg_names + assert "unless" in my_directive_arg_names end @tag :tmp_dir