You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks, I tried asking this both in slack and discord but got no replies. I'm new to GraphQL and am trying to figure out the correct way of implementing query resolvers with cursor based pagination beyond what's currently in the documentation. Here's my sample schema:
type Foo {
fooId: ID!
bars: [BarConnection!]!
}
type FooConnection {
pageInfo: PageInfo!
edges: [FooEdge!]!
}
type FooEdge {
node: Foo
cursor: Cursor!
}
type Bar {
fooId: ID!
barId: ID!
}
type BarConnection {
pageInfo: PageInfo!
edges: [BarEdge!]!
}
type BarEdge {
node: Bar
cursor: Cursor!
}
type Query {
foos(after: Cursor, first: Int): FooConnection!
bars(fooID: ID!, after: Cursor, first: Int): BarConnection!
}
I'm using gqlgen and implementing all of this in Go. I have pagination working fine for the bars() query, but I don't know what the right way to implement the foos() query is in respect to the bars field. Both Foo and Bar are tables in my DB but the Foo.Bars field is not a DB column - I'm running that select as part of the query.
In my foos() resolver I have some basic code that queries the Foo table with pagination. But I'll need to paginate through a list of Bar items for each of those results. I'm not sure how to do that in GraphQL.. I could call the bars() resolver from the foos() resolver but I''d have to keep a second set of cursor information somewhere.
Does that make sense? I haven't been able to find any examples in the wild, so I'm wondering if there's a better pattern for this use case.
The text was updated successfully, but these errors were encountered:
Hi folks, I tried asking this both in slack and discord but got no replies. I'm new to GraphQL and am trying to figure out the correct way of implementing query resolvers with cursor based pagination beyond what's currently in the documentation. Here's my sample schema:
I'm using gqlgen and implementing all of this in Go. I have pagination working fine for the
bars()
query, but I don't know what the right way to implement thefoos()
query is in respect to the bars field. Both Foo and Bar are tables in my DB but theFoo.Bars
field is not a DB column - I'm running that select as part of the query.In my
foos()
resolver I have some basic code that queries the Foo table with pagination. But I'll need to paginate through a list of Bar items for each of those results. I'm not sure how to do that in GraphQL.. I could call thebars()
resolver from thefoos()
resolver but I''d have to keep a second set of cursor information somewhere.Does that make sense? I haven't been able to find any examples in the wild, so I'm wondering if there's a better pattern for this use case.
The text was updated successfully, but these errors were encountered: