长生不老药苦艾酒自定义标量:日期时间导入错误
elixir absinthe custom scalar :datetime import error
我已经创建了很多 schema,但是当我尝试从苦艾酒中导入自定义标量类型时 :datetime
。然后它给我这样的错误
== Compilation error in file lib/project_name_web/schema.ex ==
** (Absinthe.Schema.Error) Invalid schema:
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:3: Absinthe type identifier :date is not unique.
References to types must be unique.
> All types within a GraphQL schema must have unique names. No two provided
> types may have the same name. No provided type may have a name which
> conflicts with any built in types (including Scalar and Introspection
> types).
Reference: https://github.com/facebook/graphql/blob/master/spec/Section%203%20--%20Type%20System.md#type-system
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:3: Type name "Date" is not unique.
References to types must be unique.
> All types within a GraphQL schema must have unique names. No two provided
> types may have the same name. No provided type may have a name which
> conflicts with any built in types (including Scalar and Introspection
> types).
Reference: https://github.com/facebook/graphql/blob/master/spec/Section%203%20--%20Type%20System.md#type-system
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:241: Joining_date :utc_datetime is not defined in your schema.
Types must exist if referenced.
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:253: Purchased_at :utc_datetime is not defined in your schema.
Types must exist if referenced.
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:136: Joining_date :utc_datetime is not defined in your schema.
Types must exist if referenced.
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:171: Purchased_at :utc_datetime is not defined in your schema.
Types must exist if referenced.
lib/absinthe/schema.ex:271: Absinthe.Schema.__after_compile__/2
(stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
我也导入了import_types(Absinthe.Type.Custom)
SO 从这里找到了解决方案 https://elixirforum.com/t/reusing-imported-graphql-type-definitions-in-absinthe/8519/2?u=imvinaypandya
我正在导入这个 import_types(Absinthe.Type.Custom)
每个模式(例如:user_type.ex、contact_details.ex 等)。所以我只在 schema.ex 文件中导入了一次,这对我有用。
我已经创建了很多 schema,但是当我尝试从苦艾酒中导入自定义标量类型时 :datetime
。然后它给我这样的错误
== Compilation error in file lib/project_name_web/schema.ex ==
** (Absinthe.Schema.Error) Invalid schema:
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:3: Absinthe type identifier :date is not unique.
References to types must be unique.
> All types within a GraphQL schema must have unique names. No two provided
> types may have the same name. No provided type may have a name which
> conflicts with any built in types (including Scalar and Introspection
> types).
Reference: https://github.com/facebook/graphql/blob/master/spec/Section%203%20--%20Type%20System.md#type-system
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:3: Type name "Date" is not unique.
References to types must be unique.
> All types within a GraphQL schema must have unique names. No two provided
> types may have the same name. No provided type may have a name which
> conflicts with any built in types (including Scalar and Introspection
> types).
Reference: https://github.com/facebook/graphql/blob/master/spec/Section%203%20--%20Type%20System.md#type-system
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:241: Joining_date :utc_datetime is not defined in your schema.
Types must exist if referenced.
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:253: Purchased_at :utc_datetime is not defined in your schema.
Types must exist if referenced.
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:136: Joining_date :utc_datetime is not defined in your schema.
Types must exist if referenced.
/home/vinay/Documents/project_name/lib/project_name_web/schema.ex:171: Purchased_at :utc_datetime is not defined in your schema.
Types must exist if referenced.
lib/absinthe/schema.ex:271: Absinthe.Schema.__after_compile__/2
(stdlib) erl_eval.erl:677: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
我也导入了import_types(Absinthe.Type.Custom)
SO 从这里找到了解决方案 https://elixirforum.com/t/reusing-imported-graphql-type-definitions-in-absinthe/8519/2?u=imvinaypandya
我正在导入这个 import_types(Absinthe.Type.Custom)
每个模式(例如:user_type.ex、contact_details.ex 等)。所以我只在 schema.ex 文件中导入了一次,这对我有用。