libgraphql

package
v0.0.0-...-6afd062 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(ctx context.Context, err error) error

HandleError converts an application error to a GraphQL error and records it on the active OTel span. ctx must carry the active span.

func OperationMiddleware

func OperationMiddleware(next http.Handler) http.Handler

OperationMiddleware is an HTTP middleware that reads the GraphQL request body, extracts the operationName, and enriches the active OTel span. Place it inside otelhttp.NewHandler so the span already exists in context. The body is restored so the downstream handler can read it normally.

Types

type Definition

type Definition struct {
	Translator      *libtranslator.ServiceDefinition
	GenDomain       string
	Create          *RequestConfig
	Update          *RequestConfig
	Delete          *RequestConfig
	CustomQueries   []*libtranslator.CustomRequest
	CustomCommands  []*libtranslator.CustomRequest
	DisableSelect   bool
	DisableCreate   bool
	DisableUpdate   bool
	DisableDelete   bool
	Event           bool
	FederatedEntity *FederatedEntityConfig // Apollo Federation entity config
	// contains filtered or unexported fields
}

Definition is used to declare the information of a model, so it can generate its code.

func (*Definition) Aggregate

func (d *Definition) Aggregate() *libtranslator.AggregateDefinition

func (*Definition) CustomRequests

func (d *Definition) CustomRequests() []*libtranslator.CustomRequest

type Definitions

type Definitions struct {
	Prefix         string
	Name           string
	Repository     string
	TranslatorPath string
	Tenant         bool
	Auth           bool
	Federation     *FederationConfig // Apollo Federation support
	// contains filtered or unexported fields
}

Definitions contains all the graphql definitions in the service.

func (*Definitions) GetByID

func (ds *Definitions) GetByID(id string) *Definition

GetByID return the specified definition by its ID.

func (*Definitions) GetTitle

func (ds *Definitions) GetTitle() string

GetTitle is used to return the name of the definition with InitCap

func (*Definitions) Register

func (ds *Definitions) Register(d *Definition)

Register is used to register a new definition into the service.

func (*Definitions) Slice

func (ds *Definitions) Slice() []*Definition

Slice return the definitions as a slice.

type FederatedEntityConfig

type FederatedEntityConfig struct {
	KeyFields []string // Fields for @key directive, e.g., ["id"]
	Shareable bool     // Whether multiple subgraphs can resolve this type
}

FederatedEntityConfig marks a type as an Apollo Federation entity.

type FederationConfig

type FederationConfig struct {
	Enabled bool
	Version int // 1 or 2, defaults to 2
}

FederationConfig configures Apollo Federation support for the service.

type JWTTransport

type JWTTransport struct {
	Token string
	Base  http.RoundTripper
}

JWTTransport is an http.RoundTripper that adds the x-jwt-token header. This is the header used by the gateway to forward JWT to subgraphs.

func (*JWTTransport) RoundTrip

func (t *JWTTransport) RoundTrip(req *http.Request) (*http.Response, error)

type RequestConfig

type RequestConfig struct{}

type TranslatedTerm

type TranslatedTerm struct {
	Term         gclient.String
	Translations []Translation
}

type TranslatedTermInput

type TranslatedTermInput struct {
	Term         gclient.String     `json:"term"`
	Translations []TranslationInput `json:"translations"`
}

type Translation

type Translation struct {
	Lang        gclient.String `graphql:"lang"`
	Translation gclient.String `graphql:"translation"`
}

type TranslationInput

type TranslationInput struct {
	Lang        gclient.String `json:"lang"`
	Translation gclient.String `json:"translation"`
}

type WYSIWYG

type WYSIWYG struct {
	TranslatedTerms []TranslatedTerm
	Assets          []WYSIWYGAsset
}

type WYSIWYGAsset

type WYSIWYGAsset struct {
	ID          gclient.String
	Filename    gclient.String
	ContentType gclient.String
	Size        gclient.Int
	URL         gclient.String
}

type WYSIWYGInput

type WYSIWYGInput struct {
	TranslatedTerms []TranslatedTermInput `json:"translatedTerms"`
	AssetsToAdd     []WYSIWYGAsset        `json:"assetsToAdd"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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