# HG changeset patch # User Theodor Thornhill # Date 1639086787 -3600 # Thu Dec 09 22:53:07 2021 +0100 # Node ID fa0455e16e832b477d926e071915796aa23f02be # Parent b779068057da4da2ff4dc9be80dd119371684854 Start fleshing out the introspection system It looks like we need to predefine how this whole schema works. Every resolver must be defined by us, and should be callable as a normal query. I need to read up on the entry points here. We are getting closer to a working something! diff --git a/src/introspection.lisp b/src/introspection.lisp --- a/src/introspection.lisp +++ b/src/introspection.lisp @@ -1,7 +1,7 @@ (in-package :gql) (defmacro defintrospection (name &body slots) - `(defclass ,name (ast-node) + `(defclass ,name (gql-object) ,(loop :for slot :in slots :for initarg = (intern (symbol-name slot) :keyword) :collect `(,slot :initarg ,initarg :initform nil :accessor ,slot)))) @@ -11,12 +11,22 @@ ;;; __type(name: string!): __type (defintrospection __schema + description ;; string types ;; [__type!]! query-type ;; __type! mutation-type ;; __type subscription-type ;; __type directives) ;; [__directive!]! +(defvar *__schema-resolvers* + (make-resolvers + ("description" . 'description) + ("types" . 'all-types) ;; TODO: This doesn't take an argument. Problem? + ("query-type" . 'query-type) + ("mutation-type" . 'mutation-type) + ("subscription-type" . 'subscription-type) + ("directives" . 'directives))) + (defintrospection __type kind ;; __type-kind! name ;; string @@ -28,13 +38,34 @@ input-fields ;; [__input-value!] of-type) ;; __type +(defvar *__type-resolvers* + (make-resolvers + ("kind" . 'kind) + ("name" . 'name) + ("description" . 'description) + ("fields" . 'fields) + ("interfaces" . 'interfaces) + ("possible-types" . 'possible-types) + ("enum-values" . 'enum-values) + ("input-fields" . 'input-fields) + ("of-type" . 'of-type))) + (defintrospection __field - name ;; string! - description ;; string - args ;; [__input-value!]! - ty ;; __type! - isdeprecated ;; boolean! - deprecationreason) ;; string + name ;; string! + description ;; string + args ;; [__input-value!]! + ty ;; __type! + is-deprecated ;; boolean! + deprecation-reason) ;; string + +(defvar *__field-resolvers* + (make-resolvers + ("name" . 'name) + ("description" . 'description) + ("args" . 'args) + ("ty" . 'ty) + ("is-deprecated" . 'is-deprecated) + ("deprecation-reason" . 'deprecation-reason))) (defintrospection __input-value name ;; string! @@ -42,11 +73,25 @@ ty ;; __type! defaultvalue) ;; string +(defvar *__field-resolvers* + (make-resolvers + ("name" . 'name) + ("description" . 'description) + ("ty" . 'ty) + ("default-value" . 'default-value))) + (defintrospection __enum-value - name ;; string! - description ;; string - isdeprecated ;; boolean! - deprecationreason) ;; string + name ;; string! + description ;; string + is-deprecated ;; boolean! + deprecation-reason) ;; string + +(defvar *__field-resolvers* + (make-resolvers + ("name" . 'name) + ("description" . 'description) + ("is-deprecated" . 'is-deprecated) + ("deprecation-reason" . 'deprecation-reason))) (deftype __type-kind () '(member @@ -65,6 +110,13 @@ locations ;; [__directive-location!]! args) ;; [__input-value!]! +(defvar *__directive-resolvers* + (make-resolvers + ("name" . 'name) + ("description" . 'description) + ("locations" . 'locations) + ("args" . 'args))) + (deftype __directive-location () '(member query