Fork me on GitHub
Ian Fernandez19:11:19

Hey guys, I'm new to Lacinia I'm having a problem that lacinia queries and mutations is returning me clojure maps I have to define a type on lacinia's schema.edn to return me every key to a graphql like output? query:

{  sendSms(phone: "+5552999991000") }

Ian Fernandez19:11:07


  "data": {
    "sendSms": "{:message \"SMS token was sent\", :success true, :uuid 109507373}"
{:queries {:requestAccessToken
           {:type String
            :args {:uid {:type (non-null String)}}
            :resolve :query/request-access-token}

           {:type        String
            :args        {:phone {:type String}}
            :resolve     :query/send-sms}}}


Hi again! The issue you are seeing is because your sendSms is defined to return a type String.


You should define a type that contains message, success, uuid, then use that in your sendSms type.


I’m on mobile but I’m sure the Lacinia tutorial goes over this.

Ian Fernandez19:11:36

I have to define types


I have to wonder whether the String scalar's serializer should even allow a map, or thrown an exception - this is clearly a developer error. Perhaps String should be more constrained to just a few types, like Number, Symbol, Keyword, String and not try to coerce maps and vectors and random Java objects via .toString().


We have so many breaking changes related to scalars in 0.31.0 that one more couldn't hurt ... much.


Thinking about clojure & schema types maybe something with predicates make sense? Map String graphql type to string? pred . If the return do not fit in the pred, then thow/warn. But do not do things like (str (resolver))