Skip to content

Commit

Permalink
Merge pull request #1001 from absinthe-graphql/fix-nil
Browse files Browse the repository at this point in the history
Fix `nil` schema_node in ArgumentsOfCorrectType
  • Loading branch information
binaryseed committed Dec 8, 2020
2 parents 1a03ef2 + d55f527 commit 3eb5a59
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ defmodule Absinthe.Phase.Document.Validation.ArgumentsOfCorrectType do
case Type.unwrap(node.schema_node) do
%Type.Scalar{} -> []
%Type.Enum{} -> []
nil -> []
_ -> suggested_field_names(node.schema_node, child.name)
end

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"},
"benchfella": {:hex, :benchfella, "0.3.5", "b2122c234117b3f91ed7b43b6e915e19e1ab216971154acd0a80ce0e9b8c05f5", [:mix], [], "hexpm"},
"dataloader": {:hex, :dataloader, "1.0.4", "7c2345c53c9e5b61420013fc53c8463ba347a938b61f66677eb47d9c4a53ac5d", [:mix], [{:ecto, ">= 0.0.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm", "6558d3a3e6c9f5019a68eb7cc53384dc8a1d74977c6e41b48b126dd3bfa9d0b0"},
"dataloader": {:hex, :dataloader, "1.0.8", "114294362db98a613f231589246aa5b0ce847412e8e75c4c94f31f204d272cbf", [:mix], [{:ecto, ">= 3.4.3 and < 4.0.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "eaf3c2aa2bc9dbd2f1e960561d616b7f593396c4754185b75904f6d66c82a667"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,36 @@ defmodule Absinthe.Phase.Document.Validation.ArgumentsOfCorrectTypeTest do
end
end

describe "Invalid Custom Scalar value" do
test "Invalid scalar input on mutation, no suggestion" do
assert_fails_validation(
"""
mutation($scalarInput: CustomScalar) {
createDog(customScalarInput: $scalarInput)
}
""",
[
variables: %{
"scalarInput" => [
%{
"foo" => "BAR"
}
]
}
],
[
bad_argument(
"customScalarInput",
"CustomScalar",
~s($scalarInput),
2,
[@phase.unknown_field_error_message("foo")]
)
]
)
end
end

describe "Directive arguments" do
test "with directives of valid types" do
assert_passes_validation(
Expand Down
11 changes: 11 additions & 0 deletions test/support/fixtures/pets_schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ defmodule Absinthe.Fixtures.PetsSchema do
field :string_list_field, list_of(:string)
end

scalar :custom_scalar do
parse & &1
serialize & &1
end

object :complicated_args do
field :int_arg_field, :string do
arg :int_arg, :integer
Expand Down Expand Up @@ -194,6 +199,12 @@ defmodule Absinthe.Fixtures.PetsSchema do
field :complicated_args, :complicated_args
end

mutation do
field :create_dog, :dog do
arg :custom_scalar_input, non_null(:custom_scalar)
end
end

directive :on_query do
on [:query]
end
Expand Down

0 comments on commit 3eb5a59

Please sign in to comment.