graphql

package
v0.3.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: 7 Imported by: 0

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

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

func NewGenqlientClient added in v0.3.0

func NewGenqlientClient(subdomain, apiKey string) genql.Client

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

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

NewGenqlientClientWithHTTP creates a genqlient-compatible client with a custom HTTP client for use with the generated query functions.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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