Fork me on GitHub
#graphql
<
2018-11-28
>
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

response:

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

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

orestis19:11:11

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

orestis19:11:52

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

orestis19:11:13

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

Ian Fernandez19:11:36

I have to define types

hlship21:11:25

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().

hlship21:11:27

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

souenzzo22:11:26

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))