我在Hasura (Postgres)中定义了一个表,使用原生uuid作为字段数据类型。我的目标是从Swift创建一个更新突变,但uuid类型不会隐式地从Postgres通过Hasura和Apollo映射到Swift。Hasura文档指出,uuid类型支持使用String,但是当我在更新突变中将变量定义为String!时,
mutation RedeemMagicLinkCode($code: String!, $iosIdentifierForVendor: String!) {
__typename
update_entityname(where: {code: {_eq: $code}, iosIdentifierForVendor: {_is_null: true}}, _set: {iosIdentifierForVendor: $iosIdentifierForVendor}) {
returning {
id
}
}
}我从Variable "$code" of type "String!" used in position expecting type "uuid".的Apollo代码生成构建步骤中得到一个错误。当我把它改成uuid!时,
mutation RedeemMagicLinkCode($code: uuid!, $iosIdentifierForVendor: uuid!) {
__typename
update_en...代码生成步骤完成,生成了API.swift,但是出现了编译错误Use of undeclared type 'uuid'的几个实例,这些实例现在来自于编译Apollo生成的API.swift的过程中出现的故障。
/// API.swift
...
public let operationName = "RedeemMagicLinkCode"
public var code: uuid
public var iosIdentifierForVendor: uuid
...有人能给我指出正确的方向,让Swift知道什么是uuid,或者定义我的查询,这样我就可以通过Apollo托管突变传递一个字符串作为参数吗?非常感谢!
发布于 2019-12-18 23:28:31
哦(天哪),我可能需要为这个解决方案如此简单而脸红。
我考虑了error Use of undeclared type 'uuid'加上Hasura将接受此自定义标量的String的文档...
/// API+typealias.swift
public typealias uuid = String我把上面的别名代码单独放在我的GraphQL文件所在的文件夹中的一个文件中,瞧,它工作得很好!
我对这个公共类型别名现在挂在全局范围内并不感到兴奋,但我对一个有效的数据服务感到兴奋
https://stackoverflow.com/questions/59383926
复制相似问题