-
Notifications
You must be signed in to change notification settings - Fork 12
handle cost field #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle cost field #205
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the cost field handling across the codebase to support nullable amount and currency values. The changes address scenarios where cost data may not be available from the API.
Changes:
- Updated GraphQL schema to make
amountandcurrencyfields nullable inCostSampletype - Modified generated code to use pointer types (
*float64) for nullable amount fields - Added display helper methods (
DisplayAmountandDisplayAmountUSD) to handle null values gracefully - Updated templates and command handlers to check for nil costs and display "-" as fallback
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/api/schema.graphql | Made Cost fields (amount, currency) nullable and updated documentation |
| pkg/api/zz_generated.go | Generated code changes to use pointer types for nullable amount fields |
| pkg/api/genqlient.graphql | Added @genqlient(pointer: true) directives to amount fields in queries |
| pkg/api/cost.go | Restructured Cost types, added Previous/Currency fields, and display helper methods |
| pkg/api/environment_test.go | Updated test data to use pointer types for amount fields |
| cmd/project.go | Added nil checks for Cost field before accessing display methods |
| cmd/environment.go | Added nil checks for Cost field before accessing display methods |
| cmd/templates/project.get.md.tmpl | Added conditional rendering for cost data with fallback for nil |
| cmd/templates/environment.get.md.tmpl | Added conditional rendering for cost data with fallback for nil |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR updates the CLI to align with the new GraphQL cost API and surfaces the server version in
mass version.Changes
Cost schema alignment
pkg/api/schema.graphqlfrom the live API and updatedzz_generated.go.Cost/Summary/CostSamplehandling so:costis now required onEnvironment,Project, andPackage(matchingCost!in the schema).CostSample.amountandcurrencyare nullable and modeled as pointers in Go.EnvironmentandProjectstructs to use valueCost(non-pointer), matching the now-required cost fields.mass project listandmass environment listnow readCost.Monthly/Daily.Average.Amountdirectly, rendering empty cells when amount is null.environment.get/project.gettemplates now print$<amount>when present and nothing when amount is null.Runtime behavior
pkg/api/environment_test.goto cover the newCostshape and pointeramount.Version command
mass versionto: