aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kolam/graphql.scm14
1 files changed, 11 insertions, 3 deletions
diff --git a/kolam/graphql.scm b/kolam/graphql.scm
index c8cc706..59cc34f 100644
--- a/kolam/graphql.scm
+++ b/kolam/graphql.scm
@@ -150,6 +150,14 @@
(values root #f args children))
(root (values root #f '() children)))))
+(define (resolvable-type? type)
+ "Return non-#f if TYPE is fully resolvable, that is, it is composed
+of scalar types, enum types, or lists thereof."
+ (if (list-type? type)
+ (resolvable-type? (list-type-subtype type))
+ (or (scalar-type? type)
+ (enum-type? type))))
+
(define* (eval-graphql tree parent-type #:optional parent)
(let* ((root alias args children (tree->root+alias+args+children tree))
;; TODO: Check if required args are present.
@@ -165,9 +173,9 @@
(error "Return value of resolver is of unexpected GraphQL type:"
next-parent root-type))
(when (and (not children)
- (not (or (scalar-type? underlying-type)
- (enum-type? underlying-type))))
- (error "Leaf node must be scalar or enum type:" root-field underlying-type))
+ (not (resolvable-type? underlying-type)))
+ (error "Leaf node must be a scalar type, an enum type, or lists thereof:"
+ root-field underlying-type))
(cons (or alias root)
(cond
((eq? next-parent 'null) 'null)