graphqlclient

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package graphqlclient provides a thin wrapper around the GitHub GraphQL API client with Prometheus metrics instrumentation.

GraphQLClient is safe for concurrent use.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphQLClient

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

GraphQLClient is a thin wrapper around the shurcooL githubv4 client that records metrics for each operation. Callers define their own query/mutation structs and provide an operation name for metrics tracking.

GraphQLClient is safe for concurrent use.

func NewGraphQLClient

func NewGraphQLClient(gh *github.Client) *GraphQLClient

NewGraphQLClient creates a new GraphQL client from a github.Client. It reuses the underlying HTTP client for authentication.

Example

ExampleNewGraphQLClient demonstrates creating a GraphQL client from a github.Client.

package main

import (
	"fmt"

	"chainguard.dev/driftlessaf/reconcilers/githubreconciler/graphqlclient"
	"github.com/google/go-github/v88/github"
)

func main() {
	gh, _ := github.NewClient()
	client := graphqlclient.NewGraphQLClient(gh)
	fmt.Printf("client type: %T\n", client)
}
Output:
client type: *graphqlclient.GraphQLClient

func (*GraphQLClient) Mutate

func (c *GraphQLClient) Mutate(ctx context.Context, operationName string, m any, input githubv4.Input, variables map[string]any) error

Mutate executes a GraphQL mutation and records metrics. The operationName is used to label metrics for observability. It must be a static string representing the actual name of the GraphQL operation. Do not include dynamic content, as this will cause a cardinality explosion that will break our metrics.

func (*GraphQLClient) Query

func (c *GraphQLClient) Query(ctx context.Context, operationName string, q any, variables map[string]any) error

Query executes a GraphQL query and records metrics. `operationName` is used to label metrics for observability. It must be a static string representing the actual name of the GraphQL operation. Do not include dynamic content, as this will cause a cardinality explosion that will break our metrics.

Jump to

Keyboard shortcuts

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