Skip to content

Instantly share code, notes, and snippets.

@mbuczko
Last active October 22, 2019 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbuczko/e58e3ee4a3b8dd89fff2f67a093f1ed1 to your computer and use it in GitHub Desktop.
Save mbuczko/e58e3ee4a3b8dd89fff2f67a093f1ed1 to your computer and use it in GitHub Desktop.
clojure / pathom + timeouts
(pc/defresolver res-with-timeout [_ _]
{::pc/output [:foo]}
(async/go
(let [timeout-ch (async/timeout 3000)
[ch res] (async/alts!! [(async/go
(do-my-operation-here))
timeout-ch] :priority true)]
(if (= ch timeout-ch)
(throw (ex-info "Resolver timeout" {:timeout 3000}))
res))))
(comment
"but this is less cool way to do it, better options are implementing as a resolver-transform
(https://wilkerlucio.github.io/pathom/#connect-transform) or as plugin (https://wilkerlucio.github.)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment