Fork me on GitHub
#graphql
<
2020-01-09
>
Eamonn Sullivan12:01:40

Hi all, I'm a newbie and getting a baffling error when trying to add a custom scalar DateTime type to my schema. I'm trying to use clojure.java-time and I'm getting what I suspect is an error from the underyling Java that I don't understand: No single method: start of interface: java_time.interval.AnyInterval found for function: start of protocol: AnyInterval My schema has: :scalars {:DateTime {:parse :parse-datetime :serialize :serialize-datetime}} My parsers/serializers (assuming `[java-time :as jt]): (defn parse-datetime [s] (when (string? s) (try (jt/offset-date-time s) (catch Throwable _ nil)))) (defn serialize-datetime [d] (when (jt/offset-date-time? d) (try (str (jt/offset-date-time d)) (catch Throwable _ nil)))) And I'm compiling my schema with: (`attach-scalar-transformers {:parse-datetime parse-datetime` :serialize-datetime serialize-datetime}) Does this look familiar to anyone? The examples for lacinia don't include anything with a custom scalar, that I could find, and the only example with dates uses epoch milliseconds.

Eamonn Sullivan12:01:12

The schema seems to attach the transformers OK (at least in the repl), so I suspect this might be a clojure.java-time question. I'll ask in #clojure .

Lennart Buit12:01:36

what format are your date times in?

Lennart Buit12:01:16

(i’ll continue in the other thread)