Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support more forms of async returned values.
GraphQL.js already had support for `Promise<T>` and `Promise<Array<T>>`, but not `Array<Promise<T>>`. We had assumed that resolve functions would call Promise.all when necessary based on how GraphQL had been used in the context of PHP/Hack at Facebook where `Array<Promise<T>>` is actually pretty hard to construct. In JavaScript, however, it's easy to forget a call to Promise.all and provide this kind of value. This change makes GraphQL.js aware of `Array<Promise<T>>` and importantly enables a new expression of error handling for nullable list item types (`[T]` vs `[T!]`): If the second of an array of three values fails, we can log an error accordingly and place a null value for that index. The primary structural change here is moving the error detection logic to after calling a field's `resolve` rather than before it. This means direct field `resolve` errors have to be dealt with directly, which is a little less elegant, but it means this error detection logic can be easily reused when completing the values of items in a list. Finally, this adds a more comprehensive test suite for list types in permuation with nullability and Array and Promise return types. Fixes #17
- Loading branch information