[英]Graphql mutation for a column of type UUID[]
I'm using a postgraphql autogenerated mutation to create a row with graphql in a in a postgres table that has a column of datatype UUID[]. 我正在使用postgraphql自动生成的突变在具有数据类型UUID []列的postgres表中的graphql中创建一行。
However, there doesn't seem to be a way to save this UUID[] data with graphql? 但是,似乎没有办法用graphql保存此UUID []数据吗? Is this a datatype that graphql doesn't account for or am I wrongly forming the array?
这是graphql无法说明的数据类型,还是我错误地形成了数组?
When I go to create the row in graphiql: 当我在graphiql中创建行时:
mutation {
createJob(
input: {
user_ids: ["5b7323ac-e235-4edb-bbf9-97495d9a42a1"],
instructions: "Job Instructions",
publishedDate: "2017-06-07"}
}
)
}
I get the following error: 我收到以下错误:
"message": "column \"user_ids\" is of type uuid[] but expression is of type text[]"
Is a UUID technically not stored like text? 从技术上讲,UUID是否不像文本一样存储? I've tried different ways of forming the the UUID array but nothing seems to work
我尝试了各种方法来形成UUID数组,但似乎没有任何效果
You can probably have a workaround to this problem by creating an implicit cast : 你也许可以有一个解决此问题的创建隐式转换 :
CREATE CAST (text[] AS uuid[])
WITH INOUT
AS IMPLICIT ;
PostgreSQL will automatically do the conversion from text[]
to uuid[]
; PostgreSQL将自动执行从
text[]
到uuid[]
的转换; which just seems that is the needed step. 这似乎是必需的步骤。
NOTE: The above code must be executed from "the owner of type uuid[] or text[]", which usually means: postgres
or the database owner. 注意:上面的代码必须从“ uuid []或text []类型的所有者”执行,通常表示:
postgres
或数据库所有者。
To check that it works, you may just do: 要检查其是否有效,您可以执行以下操作:
CREATE TABLE t
(
ids uuid[]
) ;
INSERT INTO t
(ids)
VALUES
(ARRAY['5b7323ac-e235-4edb-bbf9-97495d9a42a1','5b7323ac-e235-4edb-bbf9-97495d9a42a2']),
(ARRAY['6b7323ac-e235-4edb-bbf9-97495d9a42a1']) ;
... and then, test it with GraphQL
...然后使用
GraphQL
测试
This was a bug in PostGraphQL; 这是PostGraphQL中的错误; it's been fixed in version 4 (which has not been released yet, but you can install via
npm install postgraphql@next
) 它已在版本4中得到修复(尚未发布,但是您可以通过
npm install postgraphql@next
)
More information: https://github.com/postgraphql/postgraphql/issues/516 更多信息: https : //github.com/postgraphql/postgraphql/issues/516
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.