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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JSON's generate+quirks_mode to allow dumping scalar values #316

Merged
merged 1 commit into from
Oct 16, 2016
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/enum_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def validate_non_null_input(value_name)
result = GraphQL::Query::InputValidationResult.new

if !@values_by_name.key?(value_name)
result.add_problem("Expected #{JSON.dump(value_name)} to be one of: #{@values_by_name.keys.join(', ')}")
result.add_problem("Expected #{JSON.generate(value_name, quirks_mode: true)} to be one of: #{@values_by_name.keys.join(', ')}")
end

result
Expand Down
2 changes: 1 addition & 1 deletion lib/graphql/introspection/input_value_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
field :defaultValue, types.String, "A GraphQL-formatted string representing the default value for this input value." do
resolve -> (obj, args, ctx) {
value = obj.default_value
value.nil? ? nil : JSON.dump(obj.type.coerce_result(value))
value.nil? ? nil : JSON.generate(obj.type.coerce_result(value), quirks_mode: true)
}
end
end
2 changes: 1 addition & 1 deletion lib/graphql/scalar_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def coerce=(proc)
def validate_non_null_input(value)
result = Query::InputValidationResult.new
if coerce_non_null_input(value).nil?
result.add_problem("Could not coerce value #{JSON.dump(value)} to #{name}")
result.add_problem("Could not coerce value #{JSON.generate(value, quirks_mode: true)} to #{name}")
end
result
end
Expand Down