Closed everscope closed 1 year ago
The pagination implementation depends more on the server side. The ZeroQL works with whatever server exposes. For example, server graphql schema with pagination:
schema {
query: Queries
}
type Queries {
users(page: Int!, size: Int!, sorting: UserSorting!, order: SortOrder!): [User!]
}
enum UserSorting {
FirstName,
LastName
}
enum SortOrder {
DESC,
ASC
}
type User {
id: Int!
firstName: String!
lastName: String!
}
The ZeroQL call:
var page = 0;
var size = 10;
var top10Users = await client.Query(q => q.Users(page, size, UserSorting.FirstName, SortOrder.Desc, u => u.Id))
I wrote the example without IDE, so there can be syntax issues.
I have this query
query {
MyType(first: 10) {
edges {
cursor
node {
id
name
}
}
}
}
And I want to rewrite it with ZeroQl, but I cannot select MyType directly, because it is inside node
so I suppose it should be like this, but it does not work and I can not find similar examples in google
Can you post the full schema?
Sure! Example schema looks like this:
type Query {
users(first: Int after: String last: Int before: String): UsersConnection
}
type UsersConnection {
pageInfo: PageInfo!
edges: [UsersEdge!]
nodes: [User!]
}
type UsersEdge {
cursor: String!
node: User!
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
That's default schema for paging using connection's
https://graphql.org/learn/pagination/#end-of-list-counts-and-connections https://chillicream.com/docs/hotchocolate/v13/fetching-data/pagination
Oh, I see it. It is a completely different problem than I thought at the beginning.
The anonymous classes support syntax like that new { o.Id }
but they expect you to define the property when you call the method like that new { Edges = o.Edges() }
So, define the property:
var siteLocationsQuerry = _cloudServiceGraphQlClient
.Query(sitelocationsFilter, static (i, q) =>
q.SiteLocations(
where: i.Where, order: null, first: 1000,
selector: n => new
{
Edges = n.Edges(e => e.Node(n => n.Id))
}));
Oh, now I see🥲 Thank you!
Hello,
Could you add example of ZeroQl query for query with pagination to documentation? I can not find any examples in documentation
Thank you!