searchgen

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package searchgen provides the the ability to generate a search resolver

Index

Constants

This section is empty.

Variables

View Source
var SearchDirective = entgql.NewDirective("search")

Functions

This section is empty.

Types

type Object

type Object struct {
	// Name of the object
	Name string
	// Fields of the object that are searchable
	Fields []genhooks.Field
	// AdminFields of the object that are searchable
	AdminFields []genhooks.Field
}

Object is a struct to hold the object name for the bulk resolver

type Options added in v0.4.0

type Options func(*SearchPlugin)

Options is a function to set the options for the plugin

func WithEntGeneratedPackage added in v0.4.0

func WithEntGeneratedPackage(entPackage string) Options

WithEntGeneratedPackage sets the ent generated package for the gqlgen model

func WithGraphQLImport added in v0.13.0

func WithGraphQLImport(graphqlImport string) Options

WithGraphQLImport sets the import path for the graphql package

func WithIDFields added in v0.4.4

func WithIDFields(fields []string) Options

WithIDFields sets the fields that are searchable by ID to be used as equal operations instead of like

func WithIncludeAdminSearch added in v0.12.1

func WithIncludeAdminSearch(include bool) Options

WithIncludeAdminSearch enables the admin search resolver generation

func WithModelPackage added in v0.4.0

func WithModelPackage(modelPackage string) Options

WithModelPackage sets the model package for the gqlgen model

func WithRulePackage added in v0.4.10

func WithRulePackage(pkg string) Options

WithRulePackage sets the privacy rule package for the gqlgen model this is used to check for system admins

func WithSchemaPath added in v0.13.0

func WithSchemaPath(path string) Options

WithSchemaPath sets the path to the ent schema

type SearchPlugin

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

SearchPlugin is a gqlgen plugin to generate search functions

func New

func New(entPackage string) *SearchPlugin

NewSearchPlugin returns a new search plugin

func NewWithOptions added in v0.4.0

func NewWithOptions(opts ...Options) *SearchPlugin

NewWithOptions returns a new search plugin with the given options

func (SearchPlugin) GenerateCode

func (r SearchPlugin) GenerateCode(data *codegen.Data) error

GenerateCode implements api.CodeGenerator to generate the search resolver and it's helper functions

func (SearchPlugin) Name

func (r SearchPlugin) Name() string

Name returns the name of the plugin

type SearchResolverBuild

type SearchResolverBuild struct {
	// Name of the search type
	Name string
	// Objects is a list of objects to generate bulk resolvers for
	Objects []Object
	// EntImport is the ent generated package that holds the generated types
	EntImport string
	// RuleImport is the package name for the privacy rules
	RuleImport string
	// ModelImport is the package name for the gqlgen model
	ModelImport string
	// ModelPackage is the package name for the gqlgen model
	ModelPackage string
	// GraphQLImport is the import path for the graphql package
	GraphQLImport string
	// IDFields are the fields that are IDs and should be searched with equals instead of like
	IDFields []string
}

SearchResolverBuild is a struct to hold the objects for the bulk resolver

Jump to

Keyboard shortcuts

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