hugr

package module
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 49 Imported by: 0

README

The Hugr query-engine

The Hugr query engine is a part of the Hugr project, which provides a powerful and flexible GraphQL query engine designed to work with various data sources. It supports features like caching, authentication, and schema extensions, making it suitable for building scalable and efficient applications.

See the Hugr documentation for more details.

Dependencies

It used the following packages:

Features

  • Http handlers for GraphQL API
  • GraphiQL UI to execute queries
  • GraphQL schema definition and compilation
  • Data sources management
  • Schema extensions to add sub queries to existing data sources
  • Authentication and authorization
  • Caching: L1 (inmemory - bigcache) and L2 (redis, memcached or pegasus)
  • Query parsing and validation
  • Query execution
  • Transformation results (jq transformation)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParallelMutationNotSupported = errors.New("parallel mutation queries are not supported")

Functions

This section is empty.

Types

type Client added in v0.1.9

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

func NewClient added in v0.1.9

func NewClient(url string, opts ...Option) *Client

func (*Client) DataSourceStatus added in v0.1.9

func (c *Client) DataSourceStatus(ctx context.Context, name string) (string, error)

func (*Client) DescribeDataSource added in v0.1.14

func (c *Client) DescribeDataSource(ctx context.Context, name string, self bool) (string, error)

DescribeDataSource returns the description of the data source.

func (*Client) LoadDataSource added in v0.1.9

func (c *Client) LoadDataSource(ctx context.Context, name string) error

func (*Client) Ping added in v0.1.9

func (c *Client) Ping(ctx context.Context) (string, error)

func (*Client) Query added in v0.1.9

func (c *Client) Query(ctx context.Context, query string, vars map[string]any) (*types.Response, error)

func (*Client) RegisterDataSource added in v0.1.9

func (c *Client) RegisterDataSource(ctx context.Context, ds types.DataSource) error

func (*Client) UnloadDataSource added in v0.1.9

func (c *Client) UnloadDataSource(ctx context.Context, name string) error

type ClientConfig added in v0.1.9

type ClientConfig struct {
	Timeout   time.Duration
	Transport http.RoundTripper
}

type Config

type Config struct {
	DB               db.Config
	AdminUI          bool
	AdminUIFetchPath string
	Debug            bool

	AllowParallel      bool
	MaxParallelQueries int
	MaxDepth           int

	CoreDB *coredb.Source
	Auth   *auth.Config
	Cache  cache.Config
}

type Info added in v0.1.9

type Info struct {
	AdminUI bool `json:"admin_ui"`
	Debug   bool `json:"debug"`

	AllowParallel      bool `json:"allow_parallel"`
	MaxParallelQueries int  `json:"max_parallel_queries"`
	MaxDepth           int  `json:"max_depth"`

	DuckDB db.Config           `json:"duckdb"`
	CoreDB coredb.Info         `json:"coredb"`
	Auth   []auth.ProviderInfo `json:"auth"`
	Cache  cache.Config        `json:"cache"`
}

type JQRequest

type JQRequest struct {
	JQ    string  `json:"jq"`
	Query Request `json:"query"`
}

type Option added in v0.1.9

type Option func(*ClientConfig)

func WithApiKey added in v0.1.9

func WithApiKey(apiKey string) Option

func WithApiKeyCustomHeader added in v0.1.9

func WithApiKeyCustomHeader(apiKey, header string) Option

func WithTimeout added in v0.1.9

func WithTimeout(timeout time.Duration) Option

func WithToken added in v0.1.9

func WithToken(token string) Option

func WithTransport added in v0.1.9

func WithTransport(transport http.RoundTripper) Option

func WithUserInfo added in v0.1.9

func WithUserInfo(id, name string) Option

func WithUserInfoCustomHeader added in v0.1.9

func WithUserInfoCustomHeader(id, name, idHeader, nameHeader string) Option

func WithUserRole added in v0.1.9

func WithUserRole(role string) Option

func WithUserRoleCustomHeader added in v0.1.9

func WithUserRoleCustomHeader(role, header string) Option

type Request

type Request struct {
	Query         string                 `json:"query"`
	Variables     map[string]interface{} `json:"variables"`
	OperationName string                 `json:"operationName,omitempty"`
}

type Service

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

func New

func New(config Config) *Service

func (*Service) AttachRuntimeSource

func (s *Service) AttachRuntimeSource(ctx context.Context, source sources.RuntimeSource) error

func (*Service) Close

func (s *Service) Close() error

func (*Service) Commit

func (s *Service) Commit(ctx context.Context) error

func (*Service) ContextWithTx

func (s *Service) ContextWithTx(ctx context.Context) (context.Context, error)

func (*Service) CoreDBVersion added in v0.1.9

func (s *Service) CoreDBVersion() coredb.Info

func (*Service) DataSourceStatus added in v0.1.9

func (s *Service) DataSourceStatus(ctx context.Context, name string) (string, error)

func (*Service) DescribeDataSource added in v0.1.14

func (s *Service) DescribeDataSource(ctx context.Context, name string, self bool) (string, error)

DescribeDataSource returns the formatted schema definition of a data source by its name.

func (*Service) Info added in v0.1.9

func (s *Service) Info() Info

func (*Service) Init

func (s *Service) Init(ctx context.Context) (err error)

func (*Service) LoadDataSource added in v0.1.8

func (s *Service) LoadDataSource(ctx context.Context, name string) error

func (*Service) ProcessQuery

func (s *Service) ProcessQuery(ctx context.Context, catalog string, req Request) types.Response

func (*Service) Query

func (s *Service) Query(ctx context.Context, query string, vars map[string]any) (*types.Response, error)

func (*Service) QueryCatalog

func (s *Service) QueryCatalog(ctx context.Context, catalog, query string, vars map[string]any) (*types.Response, error)

func (*Service) RegisterDataSource added in v0.1.8

func (s *Service) RegisterDataSource(ctx context.Context, ds types.DataSource) error

func (*Service) Rollback

func (s *Service) Rollback(ctx context.Context) error

func (*Service) Schema

func (s *Service) Schema() *ast.Schema

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Service) UnloadDataSource added in v0.1.8

func (s *Service) UnloadDataSource(ctx context.Context, name string) error

Jump to

Keyboard shortcuts

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