【发布时间】:2020-04-10 12:40:30
【问题描述】:
我在 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 管理的突变将字符串作为参数传递?非常感谢!
【问题讨论】:
标签: swift hasura apollo-ios