再会:
我正在尝试为订阅设置我的 graphql 服务器。这是我的 schema.js
const ChatCreatedSubscription = new GraphQLObjectType({
name: "ChatCreated",
fields: () => ({
chatCreated: {
subscribe: () => pubsub.asyncIterator(CONSTANTS.Websocket.CHANNEL_CONNECT_CUSTOMER)
}
})
});
const ChatConnectedSubscription = {
chatConnected: {
subscribe: withFilter(
(_, args) => pubsub.asyncIterator(`${args.id}`),
(payload, variables) => payload.chatConnect.id === variables.id,
)
}
}
const subscriptionType = new GraphQLObjectType({
name: "Subscription",
fields: () => ({
chatCreated: ChatCreatedSubscription,
chatConnected: ChatConnectedSubscription
})
});
const schema = new GraphQLSchema({
subscription: subscriptionType
});
但是,当我尝试运行订阅服务器时出现此错误:
ERROR introspecting schema: [
{
"message": "The type of Subscription.chatCreated must be Output Type but got: undefined."
},
{
"message": "The type of Subscription.chatConnected must be Output Type but got: undefined."
}
]