gqlsingleton

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 6 Imported by: 0

Documentation

Overview

Package gqlsingleton provides singleton objects in GraphQL server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance interface {
	comparable
	io.Closer
}

Instance is the type constraint of Singleton.

type Singleton

type Singleton[T Instance] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Singleton represents a single instance GraphQL object.

func (*Singleton[T]) CreateWith

func (s *Singleton[T]) CreateWith(f func(p graphql.ResolveParams) (value T, e error)) graphql.FieldResolveFn

CreateWith wraps a create object mutation resolver with singleton lock.

func (*Singleton[T]) Get

func (s *Singleton[T]) Get() T

Get returns the object.

func (*Singleton[T]) NodeConfig

func (s *Singleton[T]) NodeConfig() (nc gqlserver.NodeConfig[T])

NodeConfig returns NodeConfig with callback functions.

func (*Singleton[T]) QueryList

func (s *Singleton[T]) QueryList(p graphql.ResolveParams) (any, error)

QueryList provides an object list query resolver. The return type is [T!]!.

Jump to

Keyboard shortcuts

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