16

I have a problem with phoenix 1.3 + absinthe.

I try this code:

schema "urls" do
  field :path, :string

  timestamps()
 end

object :url do
  field :id, :id
  field :path, :string
  field :inserted_at, :datetime
end

It work with id and path but it fails with inserted_at with:

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
Fabien Sa
  • 9,135
  • 4
  • 37
  • 44
JAlberto
  • 155
  • 1
  • 12

1 Answers1

24

datetime is not part of the default scalar types that GraphQL comes with. Here you can find out how to build custom scalar types with Absinthe. Luckily datetime scalar type is already part of Absinthe and the only thing you need to do in order to use it is to import it:

import_types Absinthe.Type.Custom
Mark Karavan
  • 2,654
  • 1
  • 18
  • 38
ventsislaf
  • 1,651
  • 12
  • 21
  • How to do it for geo location?i mean geo co-ordinates (langitude and longitude) in GraphQl – sdg Sep 02 '17 at 16:27