example

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package example provides a handwritten GraphQL client for the Aha.io API. This package serves as example code for users learning to write GraphQL clients without code generation. For production use, see the generated client in github.com/grokify/aha-go/graphql/generated.

Index

Constants

View Source
const GetFeatureQuery = `
query GetFeature($id: ID!) {
  feature(id: $id) {
    name
    description {
      markdownBody
    }
  }
}
`

GetFeatureQuery is the GraphQL query for getting a feature by reference.

View Source
const GetPageQuery = `` /* 258-byte string literal not displayed */

GetPageQuery is the GraphQL query for getting a page by reference.

View Source
const GetRequirementQuery = `
query GetRequirement($id: ID!) {
  requirement(id: $id) {
    name
    description {
      markdownBody
    }
  }
}
`

GetRequirementQuery is the GraphQL query for getting a requirement by reference.

View Source
const SearchDocumentsQuery = `` /* 296-byte string literal not displayed */

SearchDocumentsQuery is the GraphQL query for searching documents.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a GraphQL client for Aha.io.

func NewClient

func NewClient(subdomain, apiKey string) *Client

NewClient creates a new GraphQL client.

func NewClientWithHTTP

func NewClientWithHTTP(subdomain, apiKey string, httpClient *http.Client) *Client

NewClientWithHTTP creates a new GraphQL client with a custom HTTP client.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *Request) (*Response, error)

Do executes a GraphQL request and returns the raw response.

func (*Client) Endpoint

func (c *Client) Endpoint() string

Endpoint returns the GraphQL endpoint URL.

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

func (c *Client) SetEndpoint(endpoint string)

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.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

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 PageRef

type PageRef struct {
	Name         string `json:"name"`
	ReferenceNum string `json:"referenceNum"`
}

PageRef is a reference to a page.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL