bulkgen

package
v0.14.7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package bulkgen provides a gqlgen plugin to generate bulk resolver functions used for mutations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() plugin.Plugin

New returns a new plugin

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

func WithCSVFieldMappingsFile(path string) Options

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

func WithCSVGeneratedPackage(pkg string) Options

WithCSVGeneratedPackage sets the import path for the csvgenerated package

func WithCSVOutputPath added in v0.4.7

func WithCSVOutputPath(path string) Options

WithCSVOutputPath sets the file path location that CSVs are written to

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 WithModelPackage added in v0.4.0

func WithModelPackage(modelPackage string) Options

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

func NewWithOptions(opts ...Options) *Plugin

NewWithOptions returns a new plugin with the given options

func (*Plugin) GenerateCode

func (m *Plugin) GenerateCode(data *codegen.Data) error

GenerateCode generates the bulk resolver code

func (*Plugin) Name

func (m *Plugin) Name() string

Name returns the name of the plugin

Jump to

Keyboard shortcuts

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