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

Account for nil schema_node in ArgumentsOfCorrectType suggestions #1000

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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