如何在Graphql Ruby中接受嵌套查询的字段参数?

时间:2019-09-28 02:11:20

标签: graphql apollo react-apollo apollo-client graphql-ruby

我在GraphQl(Apollo JS / Graphql Ruby)中遇到此错误: Error Error: GraphQL error: Field 'pagination' doesn't accept argument 'pagination' GraphQL error: Variable $pagination is declared by Clients but not used. Reload the page and try again.

我有这个查询:

query Clients($pagination: PaginationInput) {
  clients {
     data {
       ....Fragment
     }
     pagination(pagination: $pagination) {
       ....Fragment
     }

  }
}

我将其作为输入类型:

class PaginatedClientsType < Types::BaseObject
   field :data, ...
   field :pagination, PaginationType ... do 
     argument :pagination, PaginationInput, required: false
   end
end

这在我的query_type.rb文件中:

field :clients, ::Types::Paginated::ClientsType, null: false do
   argument :pagination, PaginationInput, required: false
end

def clients(pagination:)
  ...
end

// and i've added to no avail:
field :pagination ... do
   argument :pagination, PaginationInput, required: false
end
def pagination(pagination:)
...
end

关于如何将参数传递给除此顶级client之外的其他任何想法? 我已经阅读了文档here,但无法弄清楚。

谢谢!

0 个答案:

没有答案