Passing data through a GRAPHQL Subscription gives null on only one of the arguments

前端 未结 1 1915

I have the following GRAPHQL subscription:

Schema.graphql
    type Subscription {
      booking: SubscriptionData
    }

    type SubscriptionData {
      bookin         


        
1条回答
  •  被撕碎了的回忆
    2021-01-28 23:49

    Based on your schema, the desired data returned should look like this:

    {
      "booking": {
        "booking": {
          ...
        },
        "action": "test"
      }
    }
    

    The first booking is the field on Subscription, while the second booking is the field on SubscriptionData. The object you pass to publish should have this same shape (i.e. it should always include the root-level subscription field).

    pubsub.publish('booking', {
      booking: {
        booking,
        action: 'test',
      },
    })
    

    0 讨论(0)
提交回复
热议问题