GraphQL:字段解析器未触发订阅查询?

GraphQL: Field Resolver Not Firing on Subscription Query?

我有一个订阅查询,MessageFolder_Subscription,看起来像这样:

查询

const MESSAGEFOLDER_SUBSCRIPTION_QUERY = gql`
    subscription ($localUserID: String!){
        MessageFolder_Subscription(userID: $localUserID){
            id
            remoteUserData{
                id
                name_title
                name_first
                name_last
                [...more fields...]
            }
        },
    }
`;

这是它的架构:

架构

type myUserData {
    id: String
    gender: String
    name_title: String
    name_first: String
    *[...more fields...]*
}

type messageFolder{
    id: String
    remoteUserData: myUserData
}

type Subscription {
    MessageFolder_Subscription(userID: String!): messageFolder
}

我是这样处理解析器的:

解析器

const resolvers = {
    //FIELD RESOLVER
        MessageFolder_Subscription: {
            subscribe: withFilter(
                () => pubsub.asyncIterator(MSGFOLDER_ADDED_CHANNEL),
                (payload, args) => {
                    debugger; <=== NEVER FIRES

                    if (typeof (payload) === 'undefined') {
                        return false;
                    }

                    let result = false;
                    const userId = Meteor.userId();
                     // let messageFolder = MessageFolder_Subscription.messageFolder; 
                    result = (userId === args.fromID || args === MSGFOLDERargs.toID);
                    return result;
                }
            )
        },
    //ROOT RESOLVER
        *[......more resolvers here.....]*
    Subscription: {
        MessageFolder_Subscription: {
            subscribe: withFilter(
                () => pubsub.asyncIterator(MSGFOLDER_ADDED_CHANNEL),
                (payload, args) => {
                    debugger;

                    if (typeof (payload) === 'undefined') {
                        return false;
                    }

                    let result = false;
                    const userId = Meteor.userId();
                     // let messageFolder = MessageFolder_Subscription.messageFolder; 
                    result = (userId === args.fromID || args === MSGFOLDERargs.toID);
                    return result;
                }
            )
        }
}

当我改变相关项目时,MessageFolder_Subscription 查询按预期由 pubsub 触发。追查,我可以看到它returns true

但由于某种原因,MessageFolder_Subscription 上字段 remoteUserData 的字段解析器从未触发。

我错过了什么?

已解决。我必须添加 __typename: 字段:

const messageFolder_Subscription = {
    __typename: 'messageFolder_Subscription',
    id: userID,
}

...到 MessageFolder_Subscription 订阅对象,当它在突变解析器中创建时,在传递给 pubsub.

之前