【发布时间】:2021-03-14 16:51:44
【问题描述】:
我想设置“移动”的实时列表,所以我使用了放大文档中的这个 sn-p。
func createSubscription() {
subscription = Amplify.API.subscribe(request: .subscription(of: Move.self, type: .onCreate))
dataSink = subscription?.subscriptionDataPublisher.sink {
if case let .failure(apiError) = $0 {
print("Subscription has terminated with \(apiError)")
} else {
print("Subscription has been closed successfully")
}
}
receiveValue: { result in
switch result {
case .success(let createdTodo):
print("Successfully got todo from subscription: \(createdTodo)")
case .failure(let error):
print("Got failed result with \(error.errorDescription)")
}
}
}
架构身份验证规则
type Move
@model
@auth( rules: [
{ allow: owner, ownerField: "owner", operations: [create, update, delete, read] },
])
{
但由于我将身份验证添加到“移动”类型,因此出现此错误。 GraphQLResponseError<Move>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Validation error of type MissingFieldArgument: Missing field argument owner @ \'onCreateMove\'", locations: nil, path: nil, extensions: nil)]
和Recovery suggestion: The list of GraphQLError contains service-specific messages
所以一切都在本地工作,但我认为我需要将授权传递给请求,但我找不到任何方法。有什么想法可以让我正确处理这个请求吗?
【问题讨论】:
标签: swift authentication graphql amplify