resolverutils

package
v1.52.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-2-Clause Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package resolverutils provides utility functions for GraphQL resolvers, including functions to convert GraphQL filters into query strings for database queries.

Index

Constants

This section is empty.

Variables

View Source
var (
	CheckIDField = E.FromPredicate(
		isNilID,
		func(filter *models.PlasmidListFilter) error {
			return fmt.Errorf(
				"plasmid list filter %v: id filter is not yet supported in stock query conversion",
				filter,
			)
		},
	)

	CheckInStockField = E.FromPredicate(
		isNilInStock,
		func(filter *models.PlasmidListFilter) error {
			return fmt.Errorf(
				"plasmid list filter %v: in_stock filter is not yet supported in stock query conversion",
				filter,
			)
		},
	)
)
View Source
var (
	CheckStrainIDField = E.FromPredicate(
		isNilStrainID,
		func(f *models.StrainListFilter) error {
			return fmt.Errorf(
				"strain list filter %v: id filter is not yet supported", f,
			)
		},
	)

	CheckStrainInStockField = E.FromPredicate(
		isNilStrainInStock,
		func(f *models.StrainListFilter) error {
			return fmt.Errorf(
				"strain list filter %v: in_stock filter is not yet supported", f,
			)
		},
	)
)
View Source
var (

	// LookupCtxLens accesses the request context on UserLookupState.
	LookupCtxLens = L.MakeLens(
		func(s UserLookupState) context.Context { return s.ctx },
		func(s UserLookupState, v context.Context) UserLookupState {
			s.ctx = v
			return s
		},
	)
	// LookupQueryLens accesses the user email or ID query on UserLookupState.
	LookupQueryLens = L.MakeLens(
		func(s UserLookupState) string { return s.query },
		func(s UserLookupState, v string) UserLookupState {
			s.query = v
			return s
		},
	)
	// LookupClientLens accesses the LogtoClient on UserLookupState.
	LookupClientLens = L.MakeLens(
		func(s UserLookupState) authentication.LogtoClient { return s.client },
		func(
			s UserLookupState,
			v authentication.LogtoClient,
		) UserLookupState {
			s.client = v
			return s
		},
	)
	// LookupLoggerLens accesses the logger on UserLookupState.
	LookupLoggerLens = L.MakeLens(
		func(s UserLookupState) *logrus.Entry { return s.logger },
		func(s UserLookupState, v *logrus.Entry) UserLookupState {
			s.logger = v
			return s
		},
	)
)

Functions

func BacterialAnnotationFilter

func BacterialAnnotationFilter() string

BacterialAnnotationFilter returns the annotation service filter DSL that matches strains annotated as "bacterial food source" in dicty_strain_characteristics — the sole criterion for bacterial strains.

func BuildPlasmidFieldQuery

func BuildPlasmidFieldQuery(filter *models.PlasmidListFilter) string

func FakeUser added in v1.49.1

func FakeUser() *user.User

FakeUser returns the default Dicty Stock Center user representation.

func GetCursor

func GetCursor(c *int) int64

func GetCursorFP

func GetCursorFP(cursor *int) int64

func GetFilter

func GetFilter(f *string) string

func GetLimit

func GetLimit(l *int) int64

func GetLimitFP

func GetLimitFP(limit *int) int64

func GetOntology

func GetOntology(onto string) string

func PlasmidFilterToQuery

func PlasmidFilterToQuery(filter *models.PlasmidListFilter) (string, error)

func QueryUserByEmail added in v1.49.1

func QueryUserByEmail(s UserLookupState) T.Tuple2[error, *user.User]

QueryUserByEmail resolves Query.userByEmail(email) and returns FakeUser when authentication is disabled.

func RedactedDepositorUser added in v1.49.1

func RedactedDepositorUser(email string) *user.User

RedactedDepositorUser constructs a User from a depositor email without exposing the email address or returning the Dicty Stock Center fakeUser.

func StockDepositor added in v1.49.1

func StockDepositor(s UserLookupState) T.Tuple2[error, *user.User]

StockDepositor resolves a stock depositor. An empty depositor returns FakeUser. When authentication is disabled and the depositor email is non-empty, it returns a redacted depositor user without exposing the email.

func StrainFilterToQuery

func StrainFilterToQuery(filter *models.StrainListFilter) (string, error)

func StrainFilterToQueryFP

func StrainFilterToQueryFP(filter *models.StrainListFilter) IOE.IOEither[error, string]

StrainFilterToQueryFP converts a StrainListFilter to an annotation-service internal query string, validating the filter's fields and returning an error if any are invalid or unsupported. The filter's label and summary fields are converted to regex queries, and the strain type is used to look up the appropriate query string from the strainTypeQueryMap. The filter's id and in_stocking fields are not yet supported and will cause an error if present.

func TimeWithPointer

func TimeWithPointer(pbt *timestamppb.Timestamp) *time.Time

func UserByEmail added in v1.49.1

func UserByEmail(s UserLookupState) T.Tuple2[error, *user.User]

UserByEmail resolves a User by email and returns FakeUser when authentication is disabled.

func UserByID added in v1.49.1

func UserByID(s UserLookupState) T.Tuple2[error, *user.User]

UserByID resolves Query.user(id) and returns FakeUser when authentication is disabled.

Types

type UserLookupState added in v1.49.1

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

UserLookupState carries the request context, user identifier or email, Logto client, logger, and intermediate lookup results.

Jump to

Keyboard shortcuts

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