Skip to content

Commit 279e4db

Browse files
committed
Deprecated input_fields for absinthe.schema.json
1 parent e37e285 commit 279e4db

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

mix.exs

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ defmodule Absinthe.Mixfile do
8282
{:ex_doc, "~> 0.22", only: :dev},
8383
{:benchee, ">= 1.0.0", only: :dev},
8484
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
85+
{:jason, "~> 1.0", only: :test, runtime: false},
8586
{:mix_test_watch, "~> 1.0", only: :dev, runtime: false},
8687
{:makeup_graphql, "~> 0.1.0", only: :dev}
8788
]

mix.lock

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
99
"ex_doc": {:hex, :ex_doc, "0.30.9", "d691453495c47434c0f2052b08dd91cc32bc4e1a218f86884563448ee2502dd2", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d7aaaf21e95dc5cddabf89063327e96867d00013963eadf2c6ad135506a8bc10"},
1010
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
11+
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1112
"makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
1213
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
1314
"makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},

priv/graphql/introspection.graphql

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fragment FullType on __Type {
4141
isDeprecated
4242
deprecationReason
4343
}
44-
inputFields {
44+
inputFields(includeDeprecated: true) {
4545
...InputValue
4646
}
4747
interfaces {

test/mix/tasks/absinthe.schema.json_test.exs

+41-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,28 @@ defmodule Mix.Tasks.Absinthe.Schema.JsonTest do
1010
field :item, :item
1111
end
1212

13+
mutation do
14+
field :update_item,
15+
type: :item,
16+
args: [
17+
id: [type: non_null(:string)],
18+
item: [type: non_null(:input_item)]
19+
]
20+
end
21+
1322
object :item do
1423
description "A Basic Type"
1524
field :id, :id
1625
field :name, :string
1726
end
27+
28+
input_object :input_item do
29+
description "A thing as input"
30+
field :value, :integer
31+
field :deprecated_field, :string, deprecate: true
32+
field :deprecated_field_with_reason, :string, deprecate: "reason"
33+
field :deprecated_non_null_field, non_null(:string), deprecate: true
34+
end
1835
end
1936

2037
defmodule PersistentTermTestSchema do
@@ -99,10 +116,33 @@ defmodule Mix.Tasks.Absinthe.Schema.JsonTest do
99116
test "generates a JSON file", %{tmp_dir: tmp_dir} do
100117
path = Path.join(tmp_dir, "schema.json")
101118

102-
argv = ["--schema", @test_schema, "--json-codec", @test_encoder, path]
119+
argv = ["--schema", @test_schema, path]
103120
assert Task.run(argv)
104121

105122
assert File.exists?(path)
123+
124+
decoded_schema = path |> File.read!() |> Jason.decode!()
125+
126+
# Includes deprecated fields by default
127+
input_thing_field_names =
128+
get_in(
129+
decoded_schema,
130+
[
131+
"data",
132+
"__schema",
133+
"types",
134+
Access.filter(&(&1["name"] == "InputItem")),
135+
"inputFields",
136+
Access.all(),
137+
"name"
138+
]
139+
)
140+
|> List.flatten()
141+
142+
assert "value" in input_thing_field_names
143+
assert "deprecatedField" in input_thing_field_names
144+
assert "deprecatedFieldWithReason" in input_thing_field_names
145+
assert "deprecatedNonNullField" in input_thing_field_names
106146
end
107147

108148
@tag :tmp_dir

0 commit comments

Comments
 (0)