swift - 如何将 Hasura/postgres uuid 与 apollo-ios 和 swift 一起使用
问题描述
我在 Hasura (Postgres) 中使用 nativeuuid
作为字段数据类型定义了一个表。我的目标是从 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
}
}
}
我从 Apollo 代码生成构建步骤中得到一个错误,即Variable "$code" of type "String!" used in position expecting type "uuid".
. 当我将其更改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 管理的突变将字符串作为参数传递?非常感谢!
解决方案
OM(天哪),我可能需要为这个解决方案多么简单而脸红。
我考虑了错误Use of undeclared type 'uuid'
以及 Hasura 将接受String
此自定义标量的文档...
/// API+typealias.swift
public typealias uuid = String
我将上述类型别名代码单独放在我的 GraphQL 文件所在的文件夹中的一个文件中,瞧,效果很好!
我对现在在全球范围内闲逛的这个公共类型别名并不感到兴奋,但我对工作数据服务感到兴奋
推荐阅读
- javascript - 当 flyToBounds 方法缩放多边形多边形边缘冻结
- node.js - 如何在 NodeJS API 中生成包含 eCharts 内容的 PDF
- javascript - How to pass img src as a parameter in a stateless function in next js?
- wordpress - 我的主题中的 WooCommerce 迷你购物车不起作用
- node.js - 从 Angular cli 1.7 升级到 12
- model-view-controller - 触发控制器功能
- laravel - yajra dataables - 合并列值可排序不工作 Laravel
- ios - 在 UICollectionView 中查找每行实际显示的项目数
- javascript - 根据过滤的数据更改 URL,REACT
- angular - 提示输入密码并在 Angular 8 应用程序的特定页面上进行验证