使用GraphQL Ruby是否可以让 GraphQL 订阅在订阅时也返回解析?例如:
module Types
class SampleType < GraphQL::Schema::Object
field :greeting, String, null: false
def greeting
'Howdy!'
end
end
end
class SampleSchema < GraphQL::Schema
subscription Types::SampleType
query Types::SampleType
end
SampleSchema.execute('subscription greeting { greeting }')['data'] # nil - but want the same as query
SampleSchema.execute('query greeting { greeting }')['data'] # { greeting: 'Howdy!' }
注意:已经发现这个Subscription Type文档指定resolver 的返回值不用于数据(仅授权)。