walmartlabs / lacinia

GraphQL implementation in pure Clojure
http://lacinia.readthedocs.io/en/latest/
Other
1.82k stars 160 forks source link

Subscriptions may fail to stream data to the client #440

Closed hlship closed 1 year ago

hlship commented 1 year ago

The subscriptions logic requires that every subscription have a :resolve that is passed the streamed value and returns a value to be selected from; the default :resolve is to simply return the streamed value as-is.

In 1.2 (and possibly earlier), this default is only applied to subscriptions defined via (the now deprecated) :subscriptions key of the schema; it is not applied to subscriptions defined as fields of the Subscriptions object.

In practice, this means that defining a subscription properly, but without an explicit :resolve, results in empty response maps being streamed to the client; it may also trigger non-null errors (depending on the type modifiers for the fields of the object being streamed).

The fix is to apply the default after merging :subscriptions into the Subscription fields.