How to use timestamps in absinthe? (Phoenix 1.3)
I have a problem with phoenix 1.3 + absinthe.
I am trying this code:
schema "urls" do
field :path, :string
timestamps()
end
object :url do
field :id, :id
field :path, :string
field :inserted_at, :datetime
end
Works with id
and path
, but with inserted_at
an error:
Inserted_at :datetime is not defined in your schema.
Types must exist if referenced.
lib/absinthe/schema.ex:230: Absinthe.Schema.__after_compile__/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:121: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
+3
source to share
1 answer
datetime
is not part of the standard scalar types that GraphQL ships with. Here you can learn how to create custom scalar types using Absinthe. Fortunately, the datetime scalar type is already part of Absinthe, and the only thing you need to do to use it is import it:
import_types Absinthe.Type.Custom
+6
source to share