我正在尝试所有最新版本的apollo-ios,但我想解决一个挥之不去的问题:我总是得到可选值(见下图)。

这是我已经探索过的(但仍然找不到原因)
当我创建该表时,Nullable为false。然后,我创建了一个供公众访问的视图。


使用apollo schema:download命令,下面是生成的json:schema.json
使用graphqurl命令,下面是生成的schema.graphql:schema.graphql。这是代码片段。
"""
columns and relationships of "schedule"
"""
type schedule {
activity: String
end_at: timestamptz
id: Int
"""An array relationship"""
speakers(
"""distinct select on columns"""
distinct_on: [talk_speakers_view_select_column!]
"""limit the number of rows returned"""
limit: Int
"""skip the first n rows. Use only with order_by"""
offset: Int
"""sort the rows by one or more columns"""
order_by: [talk_speakers_view_order_by!]
"""filter the rows returned"""
where: talk_speakers_view_bool_exp
): [talk_speakers_view!]!
start_at: timestamptz
talk_description: String
talk_type: String
title: String
}我怀疑id: Int似乎在模式中缺少!,这是codegen将其解释为可选的原因。但我也可能错了。下面是完整的参考https://github.com/vinamelody/MyApolloTest/tree/test的存储库
发布于 2021-06-18 11:44:16
这是因为Postgres出于某种未知的原因将视图列标记为显式可空,而不管底层列的可空性如何。
Vamshi (核心Hasura服务器开发)在本期中解释了它:https://github.com/hasura/graphql-engine/issues/1965
不过,您不需要该视图--它与执行查询相同:
query {
talks(
where: { activity: { _like: "iosconfig21%" } },
order_by: { start_at: "asc" }
}) {
id
title
start
<rest of fields>
}除了现在您有一个视图,您需要在您的Hasura元数据中管理和创建权限,就像一个常规表一样,在它从中选择的表的顶部。我的0.02美元。
如果您确实坚持在JSON响应https://graphql.org/learn/queries/中将其称为“GraphQL”,您甚至可以使用调度别名
https://stackoverflow.com/questions/68020309
复制相似问题