GraphQL Ruby 订阅执行初始查询

GraphQL Ruby Subscription Executing Initial Query

有了 GraphQL Ruby GraphQL 订阅也可以 return 在订阅时解析?例如:

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文档指定解析器的return值不用于数据(仅授权)。

GraphQL-ruby 的作者回复了一个问题:

https://github.com/rmosolgo/graphql-ruby/issues/1910

No, it's not possible to return something on an initial subscription query. I'm currently working on a new runtime for GraphQL-Ruby and I'll add this issue to my list (#1884), since many folks have asked for similar improvements to subscriptions.

所以不是现在,也许以后。