getProjectStatusUpdate fetches a single status update by its node ID via GraphQL.
(ctx context.Context, gqlClient *githubv4.Client, statusUpdateID string)
| 1408 | |
| 1409 | // getProjectStatusUpdate fetches a single status update by its node ID via GraphQL. |
| 1410 | func getProjectStatusUpdate(ctx context.Context, gqlClient *githubv4.Client, statusUpdateID string) (*mcp.CallToolResult, bool, any, error) { |
| 1411 | var q statusUpdateNodeQuery |
| 1412 | vars := map[string]any{ |
| 1413 | "id": githubv4.ID(statusUpdateID), |
| 1414 | } |
| 1415 | |
| 1416 | if err := gqlClient.Query(ctx, &q, vars); err != nil { |
| 1417 | return utils.NewToolResultError(fmt.Sprintf("%s: %v", ProjectStatusUpdateGetFailedError, err)), false, nil, nil |
| 1418 | } |
| 1419 | |
| 1420 | if q.Node.StatusUpdate.ID == nil || q.Node.StatusUpdate.ID == "" { |
| 1421 | return utils.NewToolResultError(fmt.Sprintf("%s: node is not a ProjectV2StatusUpdate or was not found", ProjectStatusUpdateGetFailedError)), false, nil, nil |
| 1422 | } |
| 1423 | |
| 1424 | update := convertToMinimalStatusUpdate(q.Node.StatusUpdate.statusUpdateNode) |
| 1425 | isPrivate := !bool(q.Node.StatusUpdate.Project.Public) |
| 1426 | |
| 1427 | r, err := json.Marshal(update) |
| 1428 | if err != nil { |
| 1429 | return nil, false, nil, fmt.Errorf("failed to marshal response: %w", err) |
| 1430 | } |
| 1431 | return utils.NewToolResultText(string(r)), isPrivate, nil, nil |
| 1432 | } |
| 1433 | |
| 1434 | // validateAndConvertToInt64 ensures the value is a number and converts it to int64. |
| 1435 | func validateAndConvertToInt64(value any) (int64, error) { |
no test coverage detected