Throw TypeError when coercing an array into a GraphQLString#925
Merged
Throw TypeError when coercing an array into a GraphQLString#925
Conversation
robzhu
commented
Jun 21, 2017
| 'The `String` scalar type represents textual data, represented as UTF-8 ' + | ||
| 'character sequences. The String type is most often used by GraphQL to ' + | ||
| 'represent free-form human-readable text.', | ||
| serialize: String, |
Contributor
Author
There was a problem hiding this comment.
Note to reviewer: thoughts on updating the serialize behavior as well? See coerceFloat
Contributor
There was a problem hiding this comment.
Yeah - I think this change is actually more compelling for serializing than parsing input values.
IvanGoncharov
added a commit
that referenced
this pull request
Jun 1, 2018
Working on #1333 I noticed that you can pass arrays as scalars in a query variable, e.g. [SWAPI example](http://graphql.org/swapi-graphql/?query=query%20(%24id%3A%20ID)%20%7B%0A%20%20person(personID%3A%20%24id)%20%7B%0A%20%20%20%20name%0A%20%20%7D%0A%7D&variables=%7B%0A%20%20%22id%22%3A%20%5B1%5D%0A%7D) This PR is based on #925 but fixing same issue for types other than `String` e.g. ```js Number([1]) // 1 ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, we were using the default JS logic to coerce arrays to strings. This PR detects and disallows conversion of arrays into strings.
#771