我有一个触发频道事件'countIncr'的变体,但是我看不到带有事件有效负载的活动的相应订阅触发。更新:我对此发布内容进行了一些更新,现在我更改标题以更代表我的位置。我收到了graphqlPlayground错误"Subscription field must return Async Iterable. Received: undefined"TGRstack复制我遇到了麻烦: https : //github.com/TGRstack/tgr-apollo-subscription-example-microservice/在没有TGRstack的情况下进行工作复制: https : //github.com/Falieson/fullstack-apollo-subscription-example前端:https: //github.com/TGRstack/tgr-apollo-subscription-example-microservice/blob/master/counter-ui/src/app/routes/Home/HomePage.tsxconst COUNTER_SUBSCRIPTION = gql`subscription onCountIncr { count}`const Counter = () => ( <Subscription subscription={COUNTER_SUBSCRIPTION} > {({ data, loading }) => { console.log({loading, data}) return loading ? <h1>Loading ...</h1> : data.count ? <h2>Counter: {data.count}</h2> : <h1>Counter Subscription Not Available</h1> }} </Subscription>)BE解析器:https : //github.com/TGRstack/tgr-apollo-subscription-example-microservice/blob/master/counter-service/src/gql/Resolvers.ts是模式:https : //github.com/TGRstack/tgr-apollo-subscription-example-microservice/blob/master/counter-service/src/gql/Schema.tsBE控制器:https://github.com/TGRstack/tgr-apollo-subscription-example-microservice/blob/master/counter-service/src/gql/Counter.tsconst count = { resolve: data => { console.log('CounterSub>', {data}) return data }, subscribe: () => pubsub.asyncIterator(['countIncr'])}const CounterSubscriptions = { count}async function countIncr(root: any, args: any, context: any) { const count = Counter.increment() await pubsub.publish('countIncr', count ) console.log('countIncr', '>>>', { count }) return count}
添加回答
举报
0/150
提交
取消