This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-13
Channels
- # aleph (8)
- # announcements (3)
- # beginners (36)
- # calva (1)
- # cider (1)
- # circleci (3)
- # clj-kondo (9)
- # cljdoc (58)
- # clojars (7)
- # clojure (70)
- # clojure-europe (13)
- # clojure-japan (1)
- # clojure-nl (8)
- # clojure-russia (2)
- # clojure-uk (7)
- # clojuredesign-podcast (4)
- # clojurescript (67)
- # clojureverse-ops (14)
- # cursive (6)
- # data-science (1)
- # datahike (3)
- # datomic (6)
- # docker (1)
- # events (2)
- # figwheel-main (9)
- # fulcro (4)
- # graalvm (33)
- # graphql (8)
- # helix (1)
- # jobs (1)
- # leiningen (3)
- # lsp (39)
- # malli (9)
- # minecraft (31)
- # nextjournal (7)
- # off-topic (6)
- # portal (22)
- # re-frame (5)
- # reitit (5)
- # remote-jobs (1)
- # shadow-cljs (55)
- # sql (22)
- # tools-build (3)
- # tools-deps (4)
- # xtdb (6)
Have any Lacinia users here run into resolvers returning null values for non-nullable fields?
When I've encountered this, it's typically a bug somewhere else in the code (a recent example that comes to mind was an UPDATE
operation inside a mutation that would only return a row from the database the first time it was called 😬).
What I'm wondering is how other people keep track or ideally prevent these issues from going unnoticed. I was thinking of hooking into Lacinia to track when a resolver is misbehaving so it gets spotted by the team building the API rather than the team consuming it…
It looks like an error
function is called whenever a resolver fails to adhere to the GraphQL schema.
I think this is where the null check can be found: https://github.com/walmartlabs/lacinia/blob/e89792945667ba6dc842c9788b896d8bb2636283/src/com/walmartlabs/lacinia/schema.clj#L1204
I see there's a callback inside the execution context but I'm not sure that's data I get to play with. https://github.com/walmartlabs/lacinia/blob/e89792945667ba6dc842c9788b896d8bb2636283/src/com/walmartlabs/lacinia/schema.clj#L947
You could check the return value in an interceptor, if any top-level errors
are present, and report it to a system like syntry or rollbar.
In our system top-level errors are generally problems we want to know 🙂
Although, when you do so, you will get both schema level errors (“This field is null and cant be”) as well as user level errors (resolvers that use resolve/with-error
or anything).
Thanks, @UHJH8MG6S @UDF11HLKC! I'll probably go the interceptor route as you suggest. 👍