func (m *CategoryMutation) ConfigCleared() bool {
	_, ok := m.clearedFields[category.FieldConfig]
	return ok
}
ConfigCleared returns if the "config" field was cleared in this mutation.
package ent
import (
	"context"
	"fmt"
	"sync"
	"time"
	"entgo.io/contrib/entgql/internal/todo/ent/category"
	"entgo.io/contrib/entgql/internal/todo/ent/predicate"
	"entgo.io/contrib/entgql/internal/todo/ent/schema/schematype"
	"entgo.io/contrib/entgql/internal/todo/ent/todo"
	"entgo.io/contrib/entgql/internal/todo/ent/verysecret"
	"entgo.io/ent"
)
const (
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne
	TypeCategory   = "Category"
	TypeTodo       = "Todo"
	TypeVerySecret = "VerySecret"
)
type CategoryMutation struct {
	config
	op            Op
	typ           string
	id            *int
	text          *string
	status        *category.Status
	_config       **schematype.CategoryConfig
	duration      *time.Duration
	addduration   *time.Duration
	count         *uint64
	addcount      *uint64
	clearedFields map[string]struct{}
	todos         map[int]struct{}
	removedtodos  map[int]struct{}
	clearedtodos  bool
	done          bool
	oldValue      func(context.Context) (*Category, error)
	predicates    []predicate.Category
}
var _ ent.Mutation = (*CategoryMutation)(nil)
type categoryOption func(*CategoryMutation)
func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
	m := &CategoryMutation{
		config:        c,
		op:            op,
		typ:           TypeCategory,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withCategoryID(id int) categoryOption {
	return func(m *CategoryMutation) {
		var (
			err   error
			once  sync.Once
			value *Category
		)
		m.oldValue = func(ctx context.Context) (*Category, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Category.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withCategory(node *Category) categoryOption {
	return func(m *CategoryMutation) {
		m.oldValue = func(context.Context) (*Category, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m CategoryMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m CategoryMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}
func (m *CategoryMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *CategoryMutation) SetText(s string) {
	m.text = &s
}
func (m *CategoryMutation) Text() (r string, exists bool) {
	v := m.text
	if v == nil {
		return
	}
	return *v, true
}
func (m *CategoryMutation) OldText(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldText is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldText requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldText: %w", err)
	}
	return oldValue.Text, nil
}
func (m *CategoryMutation) ResetText() {
	m.text = nil
}
func (m *CategoryMutation) SetStatus(c category.Status) {
	m.status = &c
}
func (m *CategoryMutation) Status() (r category.Status, exists bool) {
	v := m.status
	if v == nil {
		return
	}
	return *v, true
}
func (m *CategoryMutation) OldStatus(ctx context.Context) (v category.Status, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldStatus is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldStatus requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
	}
	return oldValue.Status, nil
}
func (m *CategoryMutation) ResetStatus() {
	m.status = nil
}
func (m *CategoryMutation) SetConfig(sc *schematype.CategoryConfig) {
	m._config = &sc
}
func (m *CategoryMutation) Config() (r *schematype.CategoryConfig, exists bool) {
	v := m._config
	if v == nil {
		return
	}
	return *v, true
}
func (m *CategoryMutation) OldConfig(ctx context.Context) (v *schematype.CategoryConfig, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldConfig is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldConfig requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldConfig: %w", err)
	}
	return oldValue.Config, nil
}
func (m *CategoryMutation) ClearConfig() {
	m._config = nil
	m.clearedFields[category.FieldConfig] = struct{}{}
}