From 602043b071085cfef2eabd19698fe8b54a574cee Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 30 Dec 2021 16:19:28 +0530 Subject: kolam: Allow leaf nodes to be list types. * kolam/graphql.scm (resolvable-type?): New function. (eval-graphql): Allow leaf nodes to be list types. --- kolam/graphql.scm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'kolam') 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) -- cgit v1.2.3