Documentation
¶
Overview ¶
Package graphql provides a GraphQL client for the Aha.io GraphQL API.
Package graphql provides GraphQL clients for the Aha.io GraphQL API.
This package provides two ways to interact with the Aha.io GraphQL API:
1. Manual client (Client) - A simple client for executing raw GraphQL queries 2. Generated client (via genqlient) - Type-safe generated functions
For the generated client, 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 the manual client, use NewClient and the Query method:
client := graphql.NewClient("mycompany", "api-key")
var result MyResponse
err := client.Query(ctx, myQuery, variables, &result)
Index ¶
- Constants
- func NewGenqlientClient(subdomain, apiKey string) genql.Client
- func NewGenqlientClientWithHTTP(subdomain, apiKey string, httpClient *http.Client) genql.Client
- type Client
- type Description
- type DocumentNode
- type Error
- type Feature
- type FeatureResponse
- type Page
- type PageRef
- type PageResponse
- type Request
- type Requirement
- type RequirementResponse
- type Response
- type SearchDocumentsResponse
- type SearchResults
Constants ¶
const GetFeatureQuery = `
query GetFeature($id: ID!) {
feature(id: $id) {
name
description {
markdownBody
}
}
}
`
GetFeatureQuery is the GraphQL query for getting a feature by reference.
const GetPageQuery = `` /* 258-byte string literal not displayed */
GetPageQuery is the GraphQL query for getting a page by reference.
const GetRequirementQuery = `
query GetRequirement($id: ID!) {
requirement(id: $id) {
name
description {
markdownBody
}
}
}
`
GetRequirementQuery is the GraphQL query for getting a requirement by reference.
const SearchDocumentsQuery = `` /* 296-byte string literal not displayed */
SearchDocumentsQuery is the GraphQL query for searching documents.
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")
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GraphQL client for Aha.io.
func NewClientWithHTTP ¶
NewClientWithHTTP creates a new GraphQL client with a custom HTTP client.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, query string, variables map[string]any, result any) error
Query executes a GraphQL query and unmarshals the data into result.
func (*Client) SetEndpoint ¶
SetEndpoint sets a custom endpoint URL (for testing).
type Description ¶
type Description struct {
MarkdownBody string `json:"markdownBody"`
}
Description contains formatted content.
type DocumentNode ¶
type DocumentNode struct {
Name string `json:"name"`
URL string `json:"url"`
SearchableID string `json:"searchableId"`
SearchableType string `json:"searchableType"`
}
DocumentNode represents a search result document.
type Error ¶
type Error struct {
Message string `json:"message"`
Path []string `json:"path,omitempty"`
Extensions any `json:"extensions,omitempty"`
}
Error represents a GraphQL error.
type Feature ¶
type Feature struct {
Name string `json:"name"`
Description *Description `json:"description"`
}
Feature represents an Aha feature from GraphQL.
type FeatureResponse ¶
type FeatureResponse struct {
Feature *Feature `json:"feature"`
}
FeatureResponse is the response from the feature query.
type Page ¶
type Page struct {
Name string `json:"name"`
Description *Description `json:"description"`
Children []PageRef `json:"children"`
Parent *PageRef `json:"parent"`
}
Page represents an Aha page/note.
type PageResponse ¶
type PageResponse struct {
Page *Page `json:"page"`
}
PageResponse is the response from the page query.
type Request ¶
type Request struct {
Query string `json:"query"`
Variables map[string]any `json:"variables,omitempty"`
}
Request represents a GraphQL request.
type Requirement ¶
type Requirement struct {
Name string `json:"name"`
Description *Description `json:"description"`
}
Requirement represents an Aha requirement from GraphQL.
type RequirementResponse ¶
type RequirementResponse struct {
Requirement *Requirement `json:"requirement"`
}
RequirementResponse is the response from the requirement query.
type Response ¶
type Response struct {
Data json.RawMessage `json:"data"`
Errors []Error `json:"errors,omitempty"`
}
Response represents a GraphQL response.
type SearchDocumentsResponse ¶
type SearchDocumentsResponse struct {
SearchDocuments SearchResults `json:"searchDocuments"`
}
SearchDocumentsResponse is the response from the searchDocuments query.
type SearchResults ¶
type SearchResults struct {
Nodes []DocumentNode `json:"nodes"`
CurrentPage int `json:"currentPage"`
TotalCount int `json:"totalCount"`
TotalPages int `json:"totalPages"`
IsLastPage bool `json:"isLastPage"`
}
SearchResults contains paginated search results.