@@ -281,12 +281,12 @@ type CursorPaginationParams struct {
281
281
}
282
282
283
283
// ToGraphQLParams converts cursor pagination parameters to GraphQL-specific parameters.
284
- func (p CursorPaginationParams ) ToGraphQLParams () (GraphQLPaginationParams , error ) {
284
+ func (p CursorPaginationParams ) ToGraphQLParams () (* GraphQLPaginationParams , error ) {
285
285
if p .PerPage > 100 {
286
- return GraphQLPaginationParams {} , fmt .Errorf ("perPage value %d exceeds maximum of 100" , p .PerPage )
286
+ return nil , fmt .Errorf ("perPage value %d exceeds maximum of 100" , p .PerPage )
287
287
}
288
288
if p .PerPage < 0 {
289
- return GraphQLPaginationParams {} , fmt .Errorf ("perPage value %d cannot be negative" , p .PerPage )
289
+ return nil , fmt .Errorf ("perPage value %d cannot be negative" , p .PerPage )
290
290
}
291
291
first := int32 (p .PerPage )
292
292
@@ -295,7 +295,7 @@ func (p CursorPaginationParams) ToGraphQLParams() (GraphQLPaginationParams, erro
295
295
after = & p .After
296
296
}
297
297
298
- return GraphQLPaginationParams {
298
+ return & GraphQLPaginationParams {
299
299
First : & first ,
300
300
After : after ,
301
301
}, nil
@@ -309,24 +309,13 @@ type GraphQLPaginationParams struct {
309
309
// ToGraphQLParams converts REST API pagination parameters to GraphQL-specific parameters.
310
310
// This converts page/perPage to first parameter for GraphQL queries.
311
311
// If After is provided, it takes precedence over page-based pagination.
312
- func (p PaginationParams ) ToGraphQLParams () (GraphQLPaginationParams , error ) {
313
- if p .PerPage > 100 {
314
- return GraphQLPaginationParams {}, fmt .Errorf ("perPage value %d exceeds maximum of 100" , p .PerPage )
315
- }
316
- if p .PerPage < 0 {
317
- return GraphQLPaginationParams {}, fmt .Errorf ("perPage value %d cannot be negative" , p .PerPage )
312
+ func (p PaginationParams ) ToGraphQLParams () (* GraphQLPaginationParams , error ) {
313
+ // Convert to CursorPaginationParams and delegate to avoid duplication
314
+ cursor := CursorPaginationParams {
315
+ PerPage : p .PerPage ,
316
+ After : p .After ,
318
317
}
319
- first := int32 (p .PerPage )
320
-
321
- var after * string
322
- if p .After != "" {
323
- after = & p .After
324
- }
325
-
326
- return GraphQLPaginationParams {
327
- First : & first ,
328
- After : after ,
329
- }, nil
318
+ return cursor .ToGraphQLParams ()
330
319
}
331
320
332
321
func MarshalledTextResult (v any ) * mcp.CallToolResult {
0 commit comments