graphql

package
v0.0.0-...-c7691f4 Latest Latest
Warning

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

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

Documentation

Overview

Package graphql provides a lightweight GraphQL endpoint. It uses operation names and key field detection rather than a full AST engine, while still returning properly typed, DB-backed responses.

IMPORTANT: The gh CLI uses shurcooL-graphql which does STRICT unmarshaling. Extra fields in the response cause errors. All responses are filtered through filterResponse() to only include fields requested in the query.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoTypeIntrospection

func DoTypeIntrospection(types map[string]string) map[string]any

DoTypeIntrospection handles all __type introspection queries used by gh CLI for feature detection (IssueFeatures, PullRequestFeatures, etc.). types is a map of alias → type name extracted during parseQuery.

func EnumResp

func EnumResp(names ...string) map[string]any

EnumResp builds a __type response with enum values.

func FieldResp

func FieldResp(names ...string) map[string]any

FieldResp builds a __type response with a list of field names.

func FieldRespWithArgs

func FieldRespWithArgs(argsMap map[string][]string, names ...string) map[string]any

FieldRespWithArgs builds a __type response where some fields have args.

func MergeInto

func MergeInto(dst, src map[string]any)

MergeInto copies top-level keys from src's "data" map into dst's "data" map. Used to combine multiple query results (e.g. search + repository).

func MergeNestedData

func MergeNestedData(dst, src map[string]any, key string)

MergeNestedData merges nested data from src's "data.key" map into dst's "data.key" map.

func TypeFields

func TypeFields(typeName string) map[string]any

TypeFields returns the introspection response for a given GraphQL type name. These match what GitHub's API returns so the CLI's feature detection works.

Types

type Server

type Server struct {
	Svc *service.Service
}

Server encapsulates all mutable state for the GraphQL handler layer. It replaces the former package-level globals so that dependencies are explicit and the package is safe for concurrent tests.

func NewServer

func NewServer(svc *service.Service) *Server

NewServer creates a Server wired to the given service.

func (*Server) Handler

func (s *Server) Handler(w http.ResponseWriter, r *http.Request)

Handler dispatches GitHub GraphQL API requests backed by the service layer.

Jump to

Keyboard shortcuts

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