Documentation
¶
Overview ¶
Package bulkgen provides a gqlgen plugin to generate bulk resolver functions used for mutations
Index ¶
- func New() plugin.Plugin
- type BulkResolverBuild
- type CSVFieldMapping
- type CSVFieldMappingsJSON
- type Object
- type Options
- func WithCSVFieldMappingsFile(path string) Options
- func WithCSVGeneratedPackage(pkg string) Options
- func WithCSVOutputPath(path string) Options
- func WithEntGeneratedPackage(entPackage string) Options
- func WithGraphQLImport(graphqlImport string) Options
- func WithModelPackage(modelPackage string) Options
- type Plugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BulkResolverBuild ¶
type BulkResolverBuild struct {
// Objects is a list of objects to generate bulk resolvers for
Objects []Object
// ModelImport is the import path for the gqlgen model
ModelImport string
// EntImport is the ent generated package that holds the generated types
EntImport string
// GraphQLImport is the import path for the graphql package
GraphQLImport string
// ModelPackage is the package name for the gqlgen model
ModelPackage string
// CSVGeneratedImport is the import path for the csvgenerated package
CSVGeneratedImport string
}
BulkResolverBuild is a struct to hold the objects for the bulk resolver
type CSVFieldMapping ¶ added in v0.14.1
type CSVFieldMapping struct {
// CSVColumn is the friendly CSV header name (e.g., AssignedToUserEmail)
CSVColumn string `json:"csvColumn"`
// TargetField is the Go field name this column maps to (e.g., AssignedToUserID)
TargetField string `json:"targetField"`
// IsSlice indicates if the field is a []string
IsSlice bool `json:"isSlice"`
}
CSVFieldMapping represents a custom CSV column that maps to a field. This structure matches the JSON format generated by entx.
type CSVFieldMappingsJSON ¶ added in v0.14.1
type CSVFieldMappingsJSON map[string][]CSVFieldMapping
CSVFieldMappingsJSON is the top-level structure for the JSON mappings file. Maps schema names to their CSV field mappings.
type Object ¶
type Object struct {
// Name of the object
Name string
// PluralName of the object
PluralName string
// Fields of the object
Fields []string
// AppendFields is the list of fields that can be appended in the update mutation
AppendFields []string
// OperationType indicates whether this is a create or delete operation
OperationType string
// HasCSVUpdateMutation indicates if this object has a CSV bulk update mutation
HasCSVUpdateMutation bool
// CSVFieldMappings contains custom CSV column mappings for this object
CSVFieldMappings []CSVFieldMapping
}
Object is a struct to hold the object name for the bulk resolver
type Options ¶ added in v0.4.0
type Options func(*Plugin)
Options is a function to set the options for the plugin
func WithCSVFieldMappingsFile ¶ added in v0.14.1
WithCSVFieldMappingsFile sets the path to the JSON file containing CSV field mappings. This file is generated by entx and contains custom CSV column definitions.
func WithCSVGeneratedPackage ¶ added in v0.14.0
WithCSVGeneratedPackage sets the import path for the csvgenerated package
func WithCSVOutputPath ¶ added in v0.4.7
WithCSVOutputPath sets the file path location that CSVs are written to
func WithEntGeneratedPackage ¶ added in v0.4.0
WithEntGeneratedPackage sets the ent generated package for the gqlgen model
func WithGraphQLImport ¶ added in v0.13.0
WithGraphQLImport sets the import path for the graphql package
func WithModelPackage ¶ added in v0.4.0
WithModelPackage sets the model package for the gqlgen model
type Plugin ¶
type Plugin struct {
// ModelPackage is the package name for the gqlgen model
ModelPackage string
// EntGeneratedPackage is the ent generated package that holds the generated types
EntGeneratedPackage string
// GraphQLImport is the import path for the graphql package
GraphQLImport string
// CSVOutputPath is the file path location that CSVs are written to
CSVOutputPath string
// CSVGeneratedPackage is the import path for the csvgenerated package
CSVGeneratedPackage string
// CSVFieldMappingsFile is the path to the JSON file containing CSV field mappings
CSVFieldMappingsFile string
}
Plugin is a gqlgen plugin to generate bulk resolver functions used for mutations
func NewWithOptions ¶ added in v0.4.0
NewWithOptions returns a new plugin with the given options
func (*Plugin) GenerateCode ¶
GenerateCode generates the bulk resolver code