Skip to content

Commit

Permalink
Merge branch 'mpenet-fix/issue-21'
Browse files Browse the repository at this point in the history
  • Loading branch information
bcarrell committed Mar 29, 2017
2 parents b3eb247 + 3f9b9dd commit f89af9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/com/walmartlabs/lacinia/internal_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
[v]
(str \` (name v) \'))

(defn sequential-or-set?
"Returns true if x is a Sequential or Set"
[x]
(or (sequential? x) (set? x)))

(defn is-internal-type-name?
"Identifies type names that are added by introspection."
[type-name]
Expand Down
6 changes: 3 additions & 3 deletions src/com/walmartlabs/lacinia/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[com.walmartlabs.lacinia.constants :as constants]
[com.walmartlabs.lacinia.internal-utils
:refer [cond-let ensure-seq map-vals map-kvs filter-vals deep-merge q
is-internal-type-name?]]
is-internal-type-name? sequential-or-set?]]
[com.walmartlabs.lacinia.resolve :refer [ResolverResult resolved-value resolve-errors resolve-as]]
[clojure.string :as str])
(:import
Expand Down Expand Up @@ -306,14 +306,14 @@
(defn ^:private enforce-single-result
[tuple]
(with-resolved-value [value tuple]
(if-not (sequential? value)
(if-not (sequential-or-set? value)
tuple
(error "Field resolver returned a collection of values, expected only a single value."))))

(defn ^:private enforce-multiple-results
[tuple]
(with-resolved-value [value tuple]
(if (sequential? value)
(if (sequential-or-set? value)
tuple
(error "Field resolver returned a single value, expected a collection of values."))))

Expand Down

0 comments on commit f89af9b

Please sign in to comment.