ToGraphQLParams converts cursor pagination parameters to GraphQL-specific parameters.
()
| 453 | |
| 454 | // ToGraphQLParams converts cursor pagination parameters to GraphQL-specific parameters. |
| 455 | func (p CursorPaginationParams) ToGraphQLParams() (*GraphQLPaginationParams, error) { |
| 456 | if p.PerPage > 100 { |
| 457 | return nil, fmt.Errorf("perPage value %d exceeds maximum of 100", p.PerPage) |
| 458 | } |
| 459 | if p.PerPage < 0 { |
| 460 | return nil, fmt.Errorf("perPage value %d cannot be negative", p.PerPage) |
| 461 | } |
| 462 | first := int32(p.PerPage) |
| 463 | |
| 464 | var after *string |
| 465 | if p.After != "" { |
| 466 | after = &p.After |
| 467 | } |
| 468 | |
| 469 | return &GraphQLPaginationParams{ |
| 470 | First: &first, |
| 471 | After: after, |
| 472 | }, nil |
| 473 | } |
| 474 | |
| 475 | type GraphQLPaginationParams struct { |
| 476 | First *int32 |