Documentation
¶
Overview ¶
Package resolverutils provides utility functions for GraphQL resolvers, including functions to convert GraphQL filters into query strings for database queries.
Index ¶
- Variables
- func BacterialAnnotationFilter() string
- func BuildPlasmidFieldQuery(filter *models.PlasmidListFilter) string
- func FakeUser() *user.User
- func GetCursor(c *int) int64
- func GetCursorFP(cursor *int) int64
- func GetFilter(f *string) string
- func GetLimit(l *int) int64
- func GetLimitFP(limit *int) int64
- func GetOntology(onto string) string
- func PlasmidFilterToQuery(filter *models.PlasmidListFilter) (string, error)
- func QueryUserByEmail(s UserLookupState) T.Tuple2[error, *user.User]
- func RedactedDepositorUser(email string) *user.User
- func StockDepositor(s UserLookupState) T.Tuple2[error, *user.User]
- func StrainFilterToQuery(filter *models.StrainListFilter) (string, error)
- func StrainFilterToQueryFP(filter *models.StrainListFilter) IOE.IOEither[error, string]
- func TimeWithPointer(pbt *timestamppb.Timestamp) *time.Time
- func UserByEmail(s UserLookupState) T.Tuple2[error, *user.User]
- func UserByID(s UserLookupState) T.Tuple2[error, *user.User]
- type UserLookupState
Constants ¶
This section is empty.
Variables ¶
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, ) }, ) )
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, ) }, ) )
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
FakeUser returns the default Dicty Stock Center user representation.
func GetCursorFP ¶
func GetLimitFP ¶
func GetOntology ¶
func PlasmidFilterToQuery ¶
func PlasmidFilterToQuery(filter *models.PlasmidListFilter) (string, error)
func QueryUserByEmail ¶ added in v1.49.1
QueryUserByEmail resolves Query.userByEmail(email) and returns FakeUser when authentication is disabled.
func RedactedDepositorUser ¶ added in v1.49.1
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
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 ¶
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
UserByEmail resolves a User by email 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.