JAl*_*rto 15 elixir phoenix-framework absinthe
我有凤凰1.3 +苦艾酒的问题.
我试试这段代码:
schema "urls" do
field :path, :string
timestamps()
end
object :url do
field :id, :id
field :path, :string
field :inserted_at, :datetime
end
Run Code Online (Sandbox Code Playgroud)
它可以使用id
,path
但它失败inserted_at
了:
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
Run Code Online (Sandbox Code Playgroud)
ven*_*laf 22
datetime
不是GraphQL附带的默认标量类型的一部分.在这里,您可以了解如何使用Absinthe构建自定义标量类型.幸运的是,datetime标量类型已经是Absinthe的一部分,为了使用它,你唯一需要做的就是导入它:
import_types Absinthe.Type.Custom
Run Code Online (Sandbox Code Playgroud)