Closed kefahi closed 2 years ago
GraphQL is not tied to any specific data store, you can implement these things in any way you want. The example from your link would look something like this:
@[GraphQL::Field]
def friends(ctx: MyContext, first: Int32?, offset: Int32?): Array(Hero)
first = 100 if first.nil?
offset = 0 if offset.nil?
rows = ctx.database_query("SELECT foo from bar LIMIT #{first} OFFSET #{offset}")
rows.map { |row| Hero.new row }
end
That was very helpful. Thank you!
It would be great if we can demonstrate how relationship, pagination and cursors could be implemented.
Here is some documentation: https://graphql.org/learn/pagination
It is easy to return a list of items e.g.
Array(Bar)
but not sure how to implement pagination.Thanks!