Skip to content

Commit

Permalink
Merge pull request #316 from astorije/astorije/fix-json
Browse files Browse the repository at this point in the history
Use JSON's generate+quirks_mode to allow dumping scalar values
  • Loading branch information
Robert Mosolgo committed Oct 16, 2016
2 parents 9686288 + 1a18b55 commit 28998fe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
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

0 comments on commit 28998fe

Please sign in to comment.