Documentation
¶
Overview ¶
Package graphql provides a type-safe GraphQL client for the Aha.io API.
Use NewGenqlientClient and the functions in the generated subpackage:
import (
"github.com/grokify/aha-go/graphql"
"github.com/grokify/aha-go/graphql/generated"
)
client := graphql.NewGenqlientClient("mycompany", "api-key")
resp, err := generated.GetFeature(ctx, client, "FEAT-123")
For example code showing how to write a GraphQL client without code generation, see the github.com/grokify/aha-go/graphql/example package.
Index ¶
- func NewGenqlientClient(subdomain, apiKey string) genql.Client
- func NewGenqlientClientWithHTTP(subdomain, apiKey string, httpClient *http.Client) genql.Client
- func ValidateRequiredFields(requirements *ScreenRequirements, providedFields map[string]any) []string
- type CustomFieldDefinition
- type CustomFieldOption
- type CustomFieldValue
- type FieldRequirement
- type ScreenRequirements
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGenqlientClient ¶ added in v0.3.0
NewGenqlientClient creates a genqlient-compatible client for use with the generated query functions in the generated subpackage.
Example:
client := graphql.NewGenqlientClient("mycompany", "my-api-key")
resp, err := generated.GetFeature(ctx, client, "FEAT-123")
func NewGenqlientClientWithHTTP ¶ added in v0.3.0
NewGenqlientClientWithHTTP creates a genqlient-compatible client with a custom HTTP client for use with the generated query functions.
func ValidateRequiredFields ¶ added in v0.4.0
func ValidateRequiredFields(requirements *ScreenRequirements, providedFields map[string]any) []string
ValidateRequiredFields checks if all required fields are provided. Returns a list of missing required field IDs/keys.
Types ¶
type CustomFieldDefinition ¶ added in v0.4.0
type CustomFieldDefinition struct {
ID string
Key string
Name string
Type string
Options []CustomFieldOption
}
CustomFieldDefinition represents a custom field definition.
func GetProjectCustomFieldDefinitions ¶ added in v0.4.0
func GetProjectCustomFieldDefinitions(ctx context.Context, client genql.Client, projectID string) ([]CustomFieldDefinition, error)
GetProjectCustomFieldDefinitions fetches all custom field definitions for a project.
type CustomFieldOption ¶ added in v0.4.0
CustomFieldOption represents an option for choice-based custom fields.
type CustomFieldValue ¶ added in v0.10.0
CustomFieldValue is a custom field value on a record, as returned by SetCustomFieldValues.
func SetCustomFieldValues ¶ added in v0.10.0
func SetCustomFieldValues( ctx context.Context, client genql.Client, recordID string, recordType generated.CustomFieldableTypeEnum, values map[string]any, ) ([]CustomFieldValue, error)
SetCustomFieldValues sets one or more custom field values on a record (Feature, Initiative, Release, and other Aha entity types - see generated.CustomFieldableTypeEnum for the full list).
values maps a custom field's API key to its new value. Values are usually plain scalars (string/number/bool) matching the custom field's type in Aha, not JSON objects.
The underlying GraphQL mutation can report field-level validation errors (e.g. an unknown key, or a value that doesn't match the custom field's type) inside a successful response payload rather than as a transport-level error - this function checks for that and returns a non-nil error in either case, so callers never see a silent no-op success.
type FieldRequirement ¶ added in v0.4.0
type FieldRequirement struct {
FieldID string
Required bool
ReadOnly bool
IsCustomField bool
CustomFieldKey string
CustomFieldName string
CustomFieldType string
}
FieldRequirement represents a field's requirement status.
type ScreenRequirements ¶ added in v0.4.0
type ScreenRequirements struct {
RecordType string
Fields []FieldRequirement
}
ScreenRequirements holds all field requirements for a screen/record type.
func GetFeatureRequirements ¶ added in v0.4.0
func GetFeatureRequirements(ctx context.Context, client genql.Client, featureID string) (*ScreenRequirements, error)
GetFeatureRequirements fetches the field requirements for features in a project. It requires an existing feature ID from the project to get the screen definition.
func (*ScreenRequirements) IsRequired ¶ added in v0.4.0
func (sr *ScreenRequirements) IsRequired(fieldIDOrKey string) bool
IsRequired checks if a field is required by ID or custom field key.
func (*ScreenRequirements) RequiredCustomFieldKeys ¶ added in v0.4.0
func (sr *ScreenRequirements) RequiredCustomFieldKeys() []string
RequiredCustomFieldKeys returns the keys of all required custom fields.
func (*ScreenRequirements) RequiredFieldIDs ¶ added in v0.4.0
func (sr *ScreenRequirements) RequiredFieldIDs() []string
RequiredFieldIDs returns the IDs of all required fields.