2017-06-17 73 views
2

我是Graphql的新手。对于简单的用例,假设我有简单的模型,Graphql ruby​​中字段和连接的区别?

class Post < ActiveRecord::Base 
    has_many :comments 
    end 

下面是我的graphql query_type.rb

PostType = GraphQL::ObjectType.define do 
#field :comments, types[CommentType] 
#connection :comments, CommentType.connection_type 
end 

两个field and connection对我的作品的代码。但是哪一条是正确的路要走。

回答

2

连接会帮你paginate通过连接到后有4个默认参数评论列表(第一,最后,后和前)在查询中,而在此领域将返回CommentType

基本清单对于更多关于分页连接,请点击这里

http://graphql.org/learn/pagination/

相关问题