Amplify/React AppSync graphql 订阅@auth 错误
Amplify/React AppSync graphql subscriptions @auth error
你好:slight_smile:
我有一个与@auth 相关的小问题。
(放大 + React + AppSync)
schema.graphql
type Ticket @model
@auth(rules: [
{allow: owner, provider: userPools},
])
{
id: ID!
status: String!
owner: String!
description: String!
}
构建 -> schema.graphql
type Subscription {
onCreateTicket(owner: String!): Ticket @aws_subscribe(mutations: ["createTicket"])
onUpdateTicket(owner: String!): Ticket @aws_subscribe(mutations: ["updateTicket"])
onDeleteTicket(owner: String!): Ticket @aws_subscribe(mutations: ["deleteTicket"])
}
所有操作(创建更新等)工作正常:
const {data: {listTickets: {items: items, nextToken}}} = await API
.graphql(graphqlOperation(listTickets, {
owner: user.username
})) as GraphQLResult;
除了订阅:
const subClient = API
.graphql(graphqlOperation(onUpdateTicket, {
owner: user.username
})) as Observable<object>;
subscription = subClient.subscribe({
next: (data: any) => console.log('subscription data:', data),
error: error => console.warn('subscription error: ', error)
});
订阅永远不会触发。
(没有错误,没有警告)
如有任何帮助,我们将不胜感激!
谢谢
它正在工作!!!
我不仅忘记在输入*中检查“所有者”,而且在下面的字段中也忘记检查。
#aws-amplify-devs 能否将此信息添加到文档中? :)
可以节省很多时间。
你好:slight_smile:
我有一个与@auth 相关的小问题。 (放大 + React + AppSync)
schema.graphql
type Ticket @model
@auth(rules: [
{allow: owner, provider: userPools},
])
{
id: ID!
status: String!
owner: String!
description: String!
}
构建 -> schema.graphql
type Subscription {
onCreateTicket(owner: String!): Ticket @aws_subscribe(mutations: ["createTicket"])
onUpdateTicket(owner: String!): Ticket @aws_subscribe(mutations: ["updateTicket"])
onDeleteTicket(owner: String!): Ticket @aws_subscribe(mutations: ["deleteTicket"])
}
所有操作(创建更新等)工作正常:
const {data: {listTickets: {items: items, nextToken}}} = await API
.graphql(graphqlOperation(listTickets, {
owner: user.username
})) as GraphQLResult;
除了订阅:
const subClient = API
.graphql(graphqlOperation(onUpdateTicket, {
owner: user.username
})) as Observable<object>;
subscription = subClient.subscribe({
next: (data: any) => console.log('subscription data:', data),
error: error => console.warn('subscription error: ', error)
});
订阅永远不会触发。 (没有错误,没有警告)
如有任何帮助,我们将不胜感激!
谢谢
它正在工作!!! 我不仅忘记在输入*中检查“所有者”,而且在下面的字段中也忘记检查。
#aws-amplify-devs 能否将此信息添加到文档中? :) 可以节省很多时间。