Skip to content

Commit

Permalink
Include deprecated directive args
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrenner committed Oct 29, 2024
1 parent 0db27b3 commit 271c434
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion priv/graphql/introspection.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ query IntrospectionQuery {
description
locations
isRepeatable
args {
args(includeDeprecated: true) {
...InputValue
}
}
Expand Down
33 changes: 33 additions & 0 deletions test/mix/tasks/absinthe.schema.json_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 271c434

Please sign in to comment.