This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-08
Channels
- # adventofcode (240)
- # beginners (87)
- # boot (4)
- # cider (27)
- # cljs-dev (20)
- # cljsrn (24)
- # clojure (365)
- # clojure-argentina (1)
- # clojure-brasil (4)
- # clojure-dev (12)
- # clojure-greece (65)
- # clojure-india (1)
- # clojure-italy (15)
- # clojure-japan (1)
- # clojure-losangeles (1)
- # clojure-madison (4)
- # clojure-poland (3)
- # clojure-russia (5)
- # clojure-spec (3)
- # clojure-uk (105)
- # clojurescript (27)
- # core-async (1)
- # core-logic (3)
- # cursive (61)
- # datomic (68)
- # devcards (4)
- # docs (27)
- # duct (67)
- # emacs (15)
- # events (1)
- # fulcro (8)
- # graphql (50)
- # lein-figwheel (1)
- # lumo (15)
- # numerical-computing (1)
- # off-topic (77)
- # om (3)
- # onyx (5)
- # parinfer (3)
- # planck (2)
- # portkey (5)
- # re-frame (4)
- # reagent (16)
- # ring (14)
- # rum (3)
- # shadow-cljs (17)
- # vim (1)
That's a map of interceptor name to interceptor map. You can replace keys in the map, or add new keys/interceptors to the map.
There's additional functions in com.walmartlabs.lacinia.pedestal.interceptors to allow you to set dependencies, to control the order of execution of the interceptors.
@hlship How do union type in Lacinia work? I’m trying to get one working but keep getting the error, “Field resolver returned an instance not tagged with a schema type.” My resolver looks like so,
(def resolve-client
^ResolverResult
(fn [context args _value]
(resolve-as
(if-let [client (db/client args)]
client
{:message "Client does not exist"}))))
My union type is that of either a client
or an error
where error
is just a message of type String
.Never mind, I got it to work! I’m not sure if this is the most efficient way or the correct way, but for those who are interested…
(def resolve-client
^ResolverResult
(fn [context args _value]
(resolve-as
(if-let [client (db/client args)]
(tag-with-type client :Client)
(tag-with-type {:message "Client does not exist"} :Error)))))
tag-with-type
is from the com.walmartlabs.lacinia.schema
namespace.
ResolverResult
and resolve-as
are from the com.walmartlabs.lacinia.resolve
namespaceSo i believe with resolve-as
its as simple as providing a second argument and that turns it into an error
(def resolve-client
^ResolverResult
(fn [context args _value]
(resolve-as
(if-let [client (db/client args)]
client
"Client does not exit" {:message "Client does not exist"}))))
Can I use composite types for field arguments?
:get-token {:type :Token
:args {:authdata {:type :AuthData}
;; :password {:type :String}
}
:resolve :authn/get-token}
:objects
......
:AuthData
{:fields {:login {:type :String}
:password {:type :String}}}
oh, thanks a lot
Exactly what I watching for
yep, I'm agreed with separate entity for input objects.
i think some of the graphiql plugins get quite picky about every thing have descriptions and things
Works as expected
I would code it as:
(if-let [client (db/client args)]
client
(resolve-as nil {:message "Client does not exist."}))
Returning a String when expecting to return a resolved object value is likely to cause other problems.It ensures that Lacinia doesn't try to select any nested fields. Further, this use makes it clear that "just client
" is the normal flow, and resolve-as
is the failure path.
Returning a string will result in Lacinia attempting to select fields inside the String; I believe that would be either an internal exception or a flurry of errors added to the response.
so for example if a user had a non null id, and i throw an error when it should be a user
You may be your explicit error and (I believe) an additional error if the field type is non-null
.
But you shouldn't use the non-null
qualifier on the type, if there's a possibility that it is not available as in this case.
Same way. When things go wrong, (resolve-as nil error)
. The big question is what goes in the error map.
So say i had a mutation on an object which had non-null fields. Should the fields be not non-null, if theres a chance that if the mutation breaks it will return nil