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

Fix field argument removed message #51

Merged
merged 2 commits into from
Mar 11, 2022
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
2 changes: 1 addition & 1 deletion lib/graphql/schema_comparator/changes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def initialize(object_type, field, argument)
end

def message
"Argument `#{argument.graphql_name}: #{argument.type.graphql_name}` was removed from field `#{object_type.graphql_name}.#{field.graphql_name}`"
"Argument `#{argument.graphql_name}: #{argument.type.to_type_signature}` was removed from field `#{object_type.graphql_name}.#{field.graphql_name}`"
end

def path
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "test_helper"

class GraphQL::SchemaComparator::Changes::FieldArgumentRemovedTest < Minitest::Test
class Type < GraphQL::Schema::Object
graphql_name "Type"

field :field, String, null: true do
argument :nullable, String, required: false
argument :non_null, String, required: true
argument :non_null_with_default, String, required: true, default_value: "bar"
end
end

def test_nullable_removed
change = GraphQL::SchemaComparator::Changes::FieldArgumentRemoved.new(
Type,
Type.fields["field"],
Type.fields["field"].arguments["nullable"],
)

assert change.breaking?
assert_equal change.message, "Argument `nullable: String` was removed from field `Type.field`"
end

def test_non_null_removed
change = GraphQL::SchemaComparator::Changes::FieldArgumentRemoved.new(
Type,
Type.fields["field"],
Type.fields["field"].arguments["nonNull"],
)

assert change.breaking?
assert_equal change.message, "Argument `nonNull: String!` was removed from field `Type.field`"
end
end