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

前端 未结 1 1912

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)
提交回复
热议问题