From 57ed4d58e37aad2a36034fe8a62d65393fb87053 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 17 Aug 2025 17:24:58 +0000 Subject: [PATCH] Add employee-related GraphQL types, queries, and mutations Co-authored-by: 9qa9km2y <9qa9km2y@nghienplus.io.vn> --- api/graphql/employee.graphqls | 58 + api/graphql/mutation.graphqls | 5 +- api/graphql/query.graphqls | 6 +- cmd/server/main.go | 5 +- internal/application/employee/dto.go | 129 + internal/application/employee/mapper.go | 96 + .../employee/mocks/mock_service.go | 141 + internal/application/employee/service.go | 461 ++ internal/domain/employee/employee.go | 313 ++ .../domain/employee/mocks/mock_repository.go | 247 + internal/domain/employee/repository.go | 57 + internal/domain/employee/value_objects.go | 289 + internal/domain/errors/errors.go | 13 + .../persistence/sql/employee_repository.go | 576 ++ .../interfaces/graphql/generated/generated.go | 4645 +++++++++++++---- .../interfaces/graphql/model/models_gen.go | 57 + .../graphql/resolver/employee.resolvers.go | 418 ++ .../interfaces/graphql/resolver/mapper.go | 101 + .../graphql/resolver/mutation.resolvers.go | 2 + .../graphql/resolver/query.resolvers.go | 2 + .../interfaces/graphql/resolver/resolver.go | 13 +- .../interfaces/graphql/resolver/validation.go | 104 + .../003_create_employees_table.down.sql | 2 + migrations/003_create_employees_table.up.sql | 28 + 24 files changed, 6728 insertions(+), 1040 deletions(-) create mode 100644 api/graphql/employee.graphqls create mode 100644 internal/application/employee/dto.go create mode 100644 internal/application/employee/mapper.go create mode 100644 internal/application/employee/mocks/mock_service.go create mode 100644 internal/application/employee/service.go create mode 100644 internal/domain/employee/employee.go create mode 100644 internal/domain/employee/mocks/mock_repository.go create mode 100644 internal/domain/employee/repository.go create mode 100644 internal/domain/employee/value_objects.go create mode 100644 internal/infrastructure/persistence/sql/employee_repository.go create mode 100644 internal/interfaces/graphql/resolver/employee.resolvers.go create mode 100644 migrations/003_create_employees_table.down.sql create mode 100644 migrations/003_create_employees_table.up.sql diff --git a/api/graphql/employee.graphqls b/api/graphql/employee.graphqls new file mode 100644 index 0000000..c46af6a --- /dev/null +++ b/api/graphql/employee.graphqls @@ -0,0 +1,58 @@ +# Employee types and inputs + +type Employee { + id: ID! + user: User! + employeeCode: String! + department: String! + position: String! + hireDate: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented + salary: Float! + status: String! + createdAt: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented + updatedAt: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented +} + +type EmployeeConnection { + edges: [EmployeeEdge!]! + pageInfo: PageInfo! +} + +type EmployeeEdge { + node: Employee! + cursor: String! +} + +input CreateEmployeeInput { + userId: ID! + employeeCode: String! + department: String! + position: String! + hireDate: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented + salary: Float! + status: String! +} + +input UpdateEmployeeInput { + employeeCode: String + department: String + position: String + hireDate: String # TODO: Change to Time scalar when custom scalar marshaling is implemented + salary: Float + status: String +} + +type CreateEmployeePayload { + employee: Employee! + errors: [Error!] +} + +type UpdateEmployeePayload { + employee: Employee! + errors: [Error!] +} + +type DeleteEmployeePayload { + success: Boolean! + errors: [Error!] +} \ No newline at end of file diff --git a/api/graphql/mutation.graphqls b/api/graphql/mutation.graphqls index aa96c54..cedaf71 100644 --- a/api/graphql/mutation.graphqls +++ b/api/graphql/mutation.graphqls @@ -1,7 +1,10 @@ -# User mutations +# User and Employee mutations type Mutation { createUser(input: CreateUserInput!): CreateUserPayload! updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload! deleteUser(id: ID!): DeleteUserPayload! + createEmployee(input: CreateEmployeeInput!): CreateEmployeePayload! + updateEmployee(id: ID!, input: UpdateEmployeeInput!): UpdateEmployeePayload! + deleteEmployee(id: ID!): DeleteEmployeePayload! } diff --git a/api/graphql/query.graphqls b/api/graphql/query.graphqls index 7aad770..2d46f9b 100644 --- a/api/graphql/query.graphqls +++ b/api/graphql/query.graphqls @@ -1,6 +1,10 @@ -# User queries +# User and Employee queries type Query { user(id: ID!): User users(first: Int, after: String): UserConnection! + employee(id: ID!): Employee + employees(first: Int, after: String): EmployeeConnection! + employeesByDepartment(department: String!, first: Int, after: String): EmployeeConnection! + employeesByStatus(status: String!, first: Int, after: String): EmployeeConnection! } diff --git a/cmd/server/main.go b/cmd/server/main.go index fcb9a6b..f48d060 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -10,6 +10,7 @@ import ( "syscall" "time" + "github.com/captain-corgi/go-graphql-example/internal/application/employee" "github.com/captain-corgi/go-graphql-example/internal/application/user" "github.com/captain-corgi/go-graphql-example/internal/infrastructure/config" "github.com/captain-corgi/go-graphql-example/internal/infrastructure/database" @@ -63,12 +64,14 @@ func NewApplication() (*Application, error) { // Initialize repositories userRepo := sql.NewUserRepository(dbManager.DB, logger) + employeeRepo := sql.NewEmployeeRepository(dbManager.DB.DB) // Initialize application services userService := user.NewService(userRepo, logger) + employeeService := employee.NewService(employeeRepo, userRepo, logger) // Initialize resolver with all dependencies - resolver := resolver.NewResolver(userService, logger) + resolver := resolver.NewResolver(userService, employeeService, logger) // Create HTTP server server := httpserver.NewServer(&cfg.Server, resolver, logger) diff --git a/internal/application/employee/dto.go b/internal/application/employee/dto.go new file mode 100644 index 0000000..172c290 --- /dev/null +++ b/internal/application/employee/dto.go @@ -0,0 +1,129 @@ +package employee + +import ( + "time" +) + +// GetEmployeeRequest represents a request to get an employee by ID +type GetEmployeeRequest struct { + ID string +} + +// GetEmployeeResponse represents a response containing an employee +type GetEmployeeResponse struct { + Employee *EmployeeDTO +} + +// ListEmployeesRequest represents a request to list employees with pagination +type ListEmployeesRequest struct { + Limit int + Cursor string +} + +// ListEmployeesResponse represents a response containing a list of employees +type ListEmployeesResponse struct { + Employees []*EmployeeDTO + NextCursor string +} + +// ListEmployeesByDepartmentRequest represents a request to list employees by department +type ListEmployeesByDepartmentRequest struct { + Department string + Limit int + Cursor string +} + +// ListEmployeesByDepartmentResponse represents a response containing a list of employees by department +type ListEmployeesByDepartmentResponse struct { + Employees []*EmployeeDTO + NextCursor string +} + +// ListEmployeesByStatusRequest represents a request to list employees by status +type ListEmployeesByStatusRequest struct { + Status string + Limit int + Cursor string +} + +// ListEmployeesByStatusResponse represents a response containing a list of employees by status +type ListEmployeesByStatusResponse struct { + Employees []*EmployeeDTO + NextCursor string +} + +// CreateEmployeeRequest represents a request to create a new employee +type CreateEmployeeRequest struct { + UserID string + EmployeeCode string + Department string + Position string + HireDate time.Time + Salary float64 + Status string +} + +// CreateEmployeeResponse represents a response containing the created employee +type CreateEmployeeResponse struct { + Employee *EmployeeDTO + Errors []ErrorDTO +} + +// UpdateEmployeeRequest represents a request to update an employee +type UpdateEmployeeRequest struct { + ID string + EmployeeCode *string + Department *string + Position *string + HireDate *time.Time + Salary *float64 + Status *string +} + +// UpdateEmployeeResponse represents a response containing the updated employee +type UpdateEmployeeResponse struct { + Employee *EmployeeDTO + Errors []ErrorDTO +} + +// DeleteEmployeeRequest represents a request to delete an employee +type DeleteEmployeeRequest struct { + ID string +} + +// DeleteEmployeeResponse represents a response indicating the result of deletion +type DeleteEmployeeResponse struct { + Success bool + Errors []ErrorDTO +} + +// EmployeeDTO represents an employee data transfer object +type EmployeeDTO struct { + ID string + UserID string + User *UserDTO + EmployeeCode string + Department string + Position string + HireDate time.Time + Salary float64 + Status string + CreatedAt time.Time + UpdatedAt time.Time +} + +// UserDTO represents a user data transfer object (for employee relationship) +type UserDTO struct { + ID string + Email string + Name string + CreatedAt time.Time + UpdatedAt time.Time +} + +// ErrorDTO represents an error data transfer object +type ErrorDTO struct { + Message string + Field string + Code string +} \ No newline at end of file diff --git a/internal/application/employee/mapper.go b/internal/application/employee/mapper.go new file mode 100644 index 0000000..c4f9aec --- /dev/null +++ b/internal/application/employee/mapper.go @@ -0,0 +1,96 @@ +package employee + +import ( + "github.com/captain-corgi/go-graphql-example/internal/domain/employee" + "github.com/captain-corgi/go-graphql-example/internal/domain/user" +) + +// MapEmployeeToDTO converts a domain employee to a DTO +func MapEmployeeToDTO(emp *employee.Employee, user *user.User) *EmployeeDTO { + if emp == nil { + return nil + } + + var userDTO *UserDTO + if user != nil { + userDTO = &UserDTO{ + ID: user.ID().String(), + Email: user.Email().String(), + Name: user.Name().String(), + CreatedAt: user.CreatedAt(), + UpdatedAt: user.UpdatedAt(), + } + } + + return &EmployeeDTO{ + ID: emp.ID().String(), + UserID: emp.UserID().String(), + User: userDTO, + EmployeeCode: emp.EmployeeCode().String(), + Department: emp.Department().String(), + Position: emp.Position().String(), + HireDate: emp.HireDate(), + Salary: emp.Salary().Value(), + Status: emp.Status().String(), + CreatedAt: emp.CreatedAt(), + UpdatedAt: emp.UpdatedAt(), + } +} + +// MapEmployeesToDTOs converts a slice of domain employees to DTOs +func MapEmployeesToDTOs(employees []*employee.Employee, users map[string]*user.User) []*EmployeeDTO { + if employees == nil { + return nil + } + + dtos := make([]*EmployeeDTO, len(employees)) + for i, emp := range employees { + var user *user.User + if users != nil { + user = users[emp.UserID().String()] + } + dtos[i] = MapEmployeeToDTO(emp, user) + } + + return dtos +} + +// MapErrorToDTO converts a domain error to a DTO +func MapErrorToDTO(err error) ErrorDTO { + if err == nil { + return ErrorDTO{} + } + + // Try to cast to domain error + if domainErr, ok := err.(interface { + Error() string + Code() string + Field() string + }); ok { + return ErrorDTO{ + Message: domainErr.Error(), + Code: domainErr.Code(), + Field: domainErr.Field(), + } + } + + // Fallback for generic errors + return ErrorDTO{ + Message: err.Error(), + Code: "UNKNOWN_ERROR", + } +} + +// MapErrorsToDTOs converts a slice of domain errors to DTOs +func MapErrorsToDTOs(errors []error) []ErrorDTO { + if errors == nil { + return nil + } + + dtos := make([]ErrorDTO, len(errors)) + for i, err := range errors { + dtos[i] = MapErrorToDTO(err) + } + + return dtos +} \ No newline at end of file diff --git a/internal/application/employee/mocks/mock_service.go b/internal/application/employee/mocks/mock_service.go new file mode 100644 index 0000000..57860f8 --- /dev/null +++ b/internal/application/employee/mocks/mock_service.go @@ -0,0 +1,141 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: service.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + employee "github.com/captain-corgi/go-graphql-example/internal/application/employee" + gomock "github.com/golang/mock/gomock" +) + +// MockService is a mock of Service interface. +type MockService struct { + ctrl *gomock.Controller + recorder *MockServiceMockRecorder +} + +// MockServiceMockRecorder is the mock recorder for MockService. +type MockServiceMockRecorder struct { + mock *MockService +} + +// NewMockService creates a new mock instance. +func NewMockService(ctrl *gomock.Controller) *MockService { + mock := &MockService{ctrl: ctrl} + mock.recorder = &MockServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockService) EXPECT() *MockServiceMockRecorder { + return m.recorder +} + +// CreateEmployee mocks base method. +func (m *MockService) CreateEmployee(ctx context.Context, req employee.CreateEmployeeRequest) (*employee.CreateEmployeeResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateEmployee", ctx, req) + ret0, _ := ret[0].(*employee.CreateEmployeeResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateEmployee indicates an expected call of CreateEmployee. +func (mr *MockServiceMockRecorder) CreateEmployee(ctx, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateEmployee", reflect.TypeOf((*MockService)(nil).CreateEmployee), ctx, req) +} + +// DeleteEmployee mocks base method. +func (m *MockService) DeleteEmployee(ctx context.Context, req employee.DeleteEmployeeRequest) (*employee.DeleteEmployeeResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteEmployee", ctx, req) + ret0, _ := ret[0].(*employee.DeleteEmployeeResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteEmployee indicates an expected call of DeleteEmployee. +func (mr *MockServiceMockRecorder) DeleteEmployee(ctx, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteEmployee", reflect.TypeOf((*MockService)(nil).DeleteEmployee), ctx, req) +} + +// GetEmployee mocks base method. +func (m *MockService) GetEmployee(ctx context.Context, req employee.GetEmployeeRequest) (*employee.GetEmployeeResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEmployee", ctx, req) + ret0, _ := ret[0].(*employee.GetEmployeeResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetEmployee indicates an expected call of GetEmployee. +func (mr *MockServiceMockRecorder) GetEmployee(ctx, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEmployee", reflect.TypeOf((*MockService)(nil).GetEmployee), ctx, req) +} + +// ListEmployees mocks base method. +func (m *MockService) ListEmployees(ctx context.Context, req employee.ListEmployeesRequest) (*employee.ListEmployeesResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListEmployees", ctx, req) + ret0, _ := ret[0].(*employee.ListEmployeesResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListEmployees indicates an expected call of ListEmployees. +func (mr *MockServiceMockRecorder) ListEmployees(ctx, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEmployees", reflect.TypeOf((*MockService)(nil).ListEmployees), ctx, req) +} + +// ListEmployeesByDepartment mocks base method. +func (m *MockService) ListEmployeesByDepartment(ctx context.Context, req employee.ListEmployeesByDepartmentRequest) (*employee.ListEmployeesByDepartmentResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListEmployeesByDepartment", ctx, req) + ret0, _ := ret[0].(*employee.ListEmployeesByDepartmentResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListEmployeesByDepartment indicates an expected call of ListEmployeesByDepartment. +func (mr *MockServiceMockRecorder) ListEmployeesByDepartment(ctx, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEmployeesByDepartment", reflect.TypeOf((*MockService)(nil).ListEmployeesByDepartment), ctx, req) +} + +// ListEmployeesByStatus mocks base method. +func (m *MockService) ListEmployeesByStatus(ctx context.Context, req employee.ListEmployeesByStatusRequest) (*employee.ListEmployeesByStatusResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListEmployeesByStatus", ctx, req) + ret0, _ := ret[0].(*employee.ListEmployeesByStatusResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListEmployeesByStatus indicates an expected call of ListEmployeesByStatus. +func (mr *MockServiceMockRecorder) ListEmployeesByStatus(ctx, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEmployeesByStatus", reflect.TypeOf((*MockService)(nil).ListEmployeesByStatus), ctx, req) +} + +// UpdateEmployee mocks base method. +func (m *MockService) UpdateEmployee(ctx context.Context, req employee.UpdateEmployeeRequest) (*employee.UpdateEmployeeResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateEmployee", ctx, req) + ret0, _ := ret[0].(*employee.UpdateEmployeeResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateEmployee indicates an expected call of UpdateEmployee. +func (mr *MockServiceMockRecorder) UpdateEmployee(ctx, req interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateEmployee", reflect.TypeOf((*MockService)(nil).UpdateEmployee), ctx, req) +} diff --git a/internal/application/employee/service.go b/internal/application/employee/service.go new file mode 100644 index 0000000..ae76fd7 --- /dev/null +++ b/internal/application/employee/service.go @@ -0,0 +1,461 @@ +package employee + +import ( + "context" + "fmt" + "log/slog" + + "github.com/captain-corgi/go-graphql-example/internal/domain/employee" + "github.com/captain-corgi/go-graphql-example/internal/domain/user" +) + +//go:generate go run github.com/golang/mock/mockgen -source=$GOFILE -destination=./mocks/mock_$GOFILE -package=mocks + +// Service defines the interface for employee application operations +type Service interface { + GetEmployee(ctx context.Context, req GetEmployeeRequest) (*GetEmployeeResponse, error) + ListEmployees(ctx context.Context, req ListEmployeesRequest) (*ListEmployeesResponse, error) + ListEmployeesByDepartment(ctx context.Context, req ListEmployeesByDepartmentRequest) (*ListEmployeesByDepartmentResponse, error) + ListEmployeesByStatus(ctx context.Context, req ListEmployeesByStatusRequest) (*ListEmployeesByStatusResponse, error) + CreateEmployee(ctx context.Context, req CreateEmployeeRequest) (*CreateEmployeeResponse, error) + UpdateEmployee(ctx context.Context, req UpdateEmployeeRequest) (*UpdateEmployeeResponse, error) + DeleteEmployee(ctx context.Context, req DeleteEmployeeRequest) (*DeleteEmployeeResponse, error) +} + +// service implements the Service interface +type service struct { + employeeRepo employee.Repository + userRepo user.Repository + logger *slog.Logger +} + +// NewService creates a new employee service +func NewService(employeeRepo employee.Repository, userRepo user.Repository, logger *slog.Logger) Service { + return &service{ + employeeRepo: employeeRepo, + userRepo: userRepo, + logger: logger, + } +} + +// GetEmployee retrieves an employee by ID +func (s *service) GetEmployee(ctx context.Context, req GetEmployeeRequest) (*GetEmployeeResponse, error) { + s.logger.Info("Getting employee", "id", req.ID) + + // Validate employee ID + employeeID, err := employee.NewEmployeeID(req.ID) + if err != nil { + s.logger.Error("Invalid employee ID", "id", req.ID, "error", err) + return &GetEmployeeResponse{}, err + } + + // Get employee from repository + emp, err := s.employeeRepo.FindByID(ctx, employeeID) + if err != nil { + s.logger.Error("Failed to get employee", "id", req.ID, "error", err) + return &GetEmployeeResponse{}, err + } + + // Get associated user + user, err := s.userRepo.FindByID(ctx, emp.UserID()) + if err != nil { + s.logger.Error("Failed to get user for employee", "user_id", emp.UserID().String(), "error", err) + // Continue without user data rather than failing completely + } + + // Map to DTO + employeeDTO := MapEmployeeToDTO(emp, user) + + s.logger.Info("Successfully retrieved employee", "id", req.ID) + return &GetEmployeeResponse{ + Employee: employeeDTO, + }, nil +} + +// ListEmployees retrieves a list of employees with pagination +func (s *service) ListEmployees(ctx context.Context, req ListEmployeesRequest) (*ListEmployeesResponse, error) { + s.logger.Info("Listing employees", "limit", req.Limit, "cursor", req.Cursor) + + // Set default limit if not provided + limit := req.Limit + if limit <= 0 { + limit = 10 + } + + // Get employees from repository + employees, nextCursor, err := s.employeeRepo.FindAll(ctx, limit, req.Cursor) + if err != nil { + s.logger.Error("Failed to list employees", "error", err) + return &ListEmployeesResponse{}, err + } + + // Get associated users + userIDs := make([]user.UserID, len(employees)) + for i, emp := range employees { + userIDs[i] = emp.UserID() + } + + users := make(map[string]*user.User) + for _, emp := range employees { + user, err := s.userRepo.FindByID(ctx, emp.UserID()) + if err != nil { + s.logger.Warn("Failed to get user for employee", "user_id", emp.UserID().String(), "error", err) + continue + } + users[emp.UserID().String()] = user + } + + // Map to DTOs + employeeDTOs := MapEmployeesToDTOs(employees, users) + + s.logger.Info("Successfully listed employees", "count", len(employeeDTOs)) + return &ListEmployeesResponse{ + Employees: employeeDTOs, + NextCursor: nextCursor, + }, nil +} + +// ListEmployeesByDepartment retrieves employees by department +func (s *service) ListEmployeesByDepartment(ctx context.Context, req ListEmployeesByDepartmentRequest) (*ListEmployeesByDepartmentResponse, error) { + s.logger.Info("Listing employees by department", "department", req.Department, "limit", req.Limit, "cursor", req.Cursor) + + // Validate department + dept, err := employee.NewDepartment(req.Department) + if err != nil { + s.logger.Error("Invalid department", "department", req.Department, "error", err) + return &ListEmployeesByDepartmentResponse{}, err + } + + // Set default limit if not provided + limit := req.Limit + if limit <= 0 { + limit = 10 + } + + // Get employees from repository + employees, nextCursor, err := s.employeeRepo.FindByDepartment(ctx, dept, limit, req.Cursor) + if err != nil { + s.logger.Error("Failed to list employees by department", "department", req.Department, "error", err) + return &ListEmployeesByDepartmentResponse{}, err + } + + // Get associated users + users := make(map[string]*user.User) + for _, emp := range employees { + user, err := s.userRepo.FindByID(ctx, emp.UserID()) + if err != nil { + s.logger.Warn("Failed to get user for employee", "user_id", emp.UserID().String(), "error", err) + continue + } + users[emp.UserID().String()] = user + } + + // Map to DTOs + employeeDTOs := MapEmployeesToDTOs(employees, users) + + s.logger.Info("Successfully listed employees by department", "department", req.Department, "count", len(employeeDTOs)) + return &ListEmployeesByDepartmentResponse{ + Employees: employeeDTOs, + NextCursor: nextCursor, + }, nil +} + +// ListEmployeesByStatus retrieves employees by status +func (s *service) ListEmployeesByStatus(ctx context.Context, req ListEmployeesByStatusRequest) (*ListEmployeesByStatusResponse, error) { + s.logger.Info("Listing employees by status", "status", req.Status, "limit", req.Limit, "cursor", req.Cursor) + + // Validate status + status, err := employee.NewStatus(req.Status) + if err != nil { + s.logger.Error("Invalid status", "status", req.Status, "error", err) + return &ListEmployeesByStatusResponse{}, err + } + + // Set default limit if not provided + limit := req.Limit + if limit <= 0 { + limit = 10 + } + + // Get employees from repository + employees, nextCursor, err := s.employeeRepo.FindByStatus(ctx, status, limit, req.Cursor) + if err != nil { + s.logger.Error("Failed to list employees by status", "status", req.Status, "error", err) + return &ListEmployeesByStatusResponse{}, err + } + + // Get associated users + users := make(map[string]*user.User) + for _, emp := range employees { + user, err := s.userRepo.FindByID(ctx, emp.UserID()) + if err != nil { + s.logger.Warn("Failed to get user for employee", "user_id", emp.UserID().String(), "error", err) + continue + } + users[emp.UserID().String()] = user + } + + // Map to DTOs + employeeDTOs := MapEmployeesToDTOs(employees, users) + + s.logger.Info("Successfully listed employees by status", "status", req.Status, "count", len(employeeDTOs)) + return &ListEmployeesByStatusResponse{ + Employees: employeeDTOs, + NextCursor: nextCursor, + }, nil +} + +// CreateEmployee creates a new employee +func (s *service) CreateEmployee(ctx context.Context, req CreateEmployeeRequest) (*CreateEmployeeResponse, error) { + s.logger.Info("Creating employee", "user_id", req.UserID, "employee_code", req.EmployeeCode) + + var errors []error + + // Validate user ID + userID, err := user.NewUserID(req.UserID) + if err != nil { + s.logger.Error("Invalid user ID", "user_id", req.UserID, "error", err) + errors = append(errors, err) + } + + // Check if user exists + if err == nil { + _, err = s.userRepo.FindByID(ctx, userID) + if err != nil { + s.logger.Error("User not found", "user_id", req.UserID, "error", err) + errors = append(errors, err) + } + } + + // Check if employee already exists for this user + if err == nil { + exists, err := s.employeeRepo.ExistsByUserID(ctx, userID) + if err != nil { + s.logger.Error("Failed to check if employee exists", "user_id", req.UserID, "error", err) + errors = append(errors, err) + } else if exists { + s.logger.Error("Employee already exists for user", "user_id", req.UserID) + errors = append(errors, fmt.Errorf("employee already exists for user")) + } + } + + // Check if employee code already exists + employeeCode, err := employee.NewEmployeeCode(req.EmployeeCode) + if err != nil { + s.logger.Error("Invalid employee code", "employee_code", req.EmployeeCode, "error", err) + errors = append(errors, err) + } else { + exists, err := s.employeeRepo.ExistsByEmployeeCode(ctx, employeeCode) + if err != nil { + s.logger.Error("Failed to check if employee code exists", "employee_code", req.EmployeeCode, "error", err) + errors = append(errors, err) + } else if exists { + s.logger.Error("Employee code already exists", "employee_code", req.EmployeeCode) + errors = append(errors, fmt.Errorf("employee code already exists")) + } + } + + // If there are validation errors, return them + if len(errors) > 0 { + return &CreateEmployeeResponse{ + Errors: MapErrorsToDTOs(errors), + }, nil + } + + // Create employee domain entity + emp, err := employee.NewEmployee( + userID, + req.EmployeeCode, + req.Department, + req.Position, + req.HireDate, + req.Salary, + req.Status, + ) + if err != nil { + s.logger.Error("Failed to create employee entity", "error", err) + return &CreateEmployeeResponse{ + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + // Validate employee + if err := emp.Validate(); err != nil { + s.logger.Error("Employee validation failed", "error", err) + return &CreateEmployeeResponse{ + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + // Save to repository + if err := s.employeeRepo.Create(ctx, emp); err != nil { + s.logger.Error("Failed to save employee", "error", err) + return &CreateEmployeeResponse{ + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + // Get associated user for response + user, err := s.userRepo.FindByID(ctx, emp.UserID()) + if err != nil { + s.logger.Warn("Failed to get user for created employee", "user_id", emp.UserID().String(), "error", err) + } + + // Map to DTO + employeeDTO := MapEmployeeToDTO(emp, user) + + s.logger.Info("Successfully created employee", "id", emp.ID().String()) + return &CreateEmployeeResponse{ + Employee: employeeDTO, + }, nil +} + +// UpdateEmployee updates an existing employee +func (s *service) UpdateEmployee(ctx context.Context, req UpdateEmployeeRequest) (*UpdateEmployeeResponse, error) { + s.logger.Info("Updating employee", "id", req.ID) + + var errors []error + + // Validate employee ID + employeeID, err := employee.NewEmployeeID(req.ID) + if err != nil { + s.logger.Error("Invalid employee ID", "id", req.ID, "error", err) + errors = append(errors, err) + } + + // Get existing employee + var emp *employee.Employee + if err == nil { + emp, err = s.employeeRepo.FindByID(ctx, employeeID) + if err != nil { + s.logger.Error("Employee not found", "id", req.ID, "error", err) + errors = append(errors, err) + } + } + + // If there are validation errors, return them + if len(errors) > 0 { + return &UpdateEmployeeResponse{ + Errors: MapErrorsToDTOs(errors), + }, nil + } + + // Update fields if provided + if req.EmployeeCode != nil { + if err := emp.UpdateEmployeeCode(*req.EmployeeCode); err != nil { + s.logger.Error("Failed to update employee code", "employee_code", *req.EmployeeCode, "error", err) + errors = append(errors, err) + } + } + + if req.Department != nil { + if err := emp.UpdateDepartment(*req.Department); err != nil { + s.logger.Error("Failed to update department", "department", *req.Department, "error", err) + errors = append(errors, err) + } + } + + if req.Position != nil { + if err := emp.UpdatePosition(*req.Position); err != nil { + s.logger.Error("Failed to update position", "position", *req.Position, "error", err) + errors = append(errors, err) + } + } + + if req.HireDate != nil { + if err := emp.UpdateHireDate(*req.HireDate); err != nil { + s.logger.Error("Failed to update hire date", "hire_date", *req.HireDate, "error", err) + errors = append(errors, err) + } + } + + if req.Salary != nil { + if err := emp.UpdateSalary(*req.Salary); err != nil { + s.logger.Error("Failed to update salary", "salary", *req.Salary, "error", err) + errors = append(errors, err) + } + } + + if req.Status != nil { + if err := emp.UpdateStatus(*req.Status); err != nil { + s.logger.Error("Failed to update status", "status", *req.Status, "error", err) + errors = append(errors, err) + } + } + + // If there are update errors, return them + if len(errors) > 0 { + return &UpdateEmployeeResponse{ + Errors: MapErrorsToDTOs(errors), + }, nil + } + + // Validate employee + if err := emp.Validate(); err != nil { + s.logger.Error("Employee validation failed", "error", err) + return &UpdateEmployeeResponse{ + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + // Save to repository + if err := s.employeeRepo.Update(ctx, emp); err != nil { + s.logger.Error("Failed to save employee", "error", err) + return &UpdateEmployeeResponse{ + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + // Get associated user for response + user, err := s.userRepo.FindByID(ctx, emp.UserID()) + if err != nil { + s.logger.Warn("Failed to get user for updated employee", "user_id", emp.UserID().String(), "error", err) + } + + // Map to DTO + employeeDTO := MapEmployeeToDTO(emp, user) + + s.logger.Info("Successfully updated employee", "id", req.ID) + return &UpdateEmployeeResponse{ + Employee: employeeDTO, + }, nil +} + +// DeleteEmployee deletes an employee +func (s *service) DeleteEmployee(ctx context.Context, req DeleteEmployeeRequest) (*DeleteEmployeeResponse, error) { + s.logger.Info("Deleting employee", "id", req.ID) + + // Validate employee ID + employeeID, err := employee.NewEmployeeID(req.ID) + if err != nil { + s.logger.Error("Invalid employee ID", "id", req.ID, "error", err) + return &DeleteEmployeeResponse{ + Success: false, + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + // Check if employee exists + _, err = s.employeeRepo.FindByID(ctx, employeeID) + if err != nil { + s.logger.Error("Employee not found", "id", req.ID, "error", err) + return &DeleteEmployeeResponse{ + Success: false, + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + // Delete from repository + if err := s.employeeRepo.Delete(ctx, employeeID); err != nil { + s.logger.Error("Failed to delete employee", "error", err) + return &DeleteEmployeeResponse{ + Success: false, + Errors: []ErrorDTO{MapErrorToDTO(err)}, + }, nil + } + + s.logger.Info("Successfully deleted employee", "id", req.ID) + return &DeleteEmployeeResponse{ + Success: true, + }, nil +} \ No newline at end of file diff --git a/internal/domain/employee/employee.go b/internal/domain/employee/employee.go new file mode 100644 index 0000000..7668924 --- /dev/null +++ b/internal/domain/employee/employee.go @@ -0,0 +1,313 @@ +package employee + +import ( + "time" + + "github.com/captain-corgi/go-graphql-example/internal/domain/errors" + "github.com/captain-corgi/go-graphql-example/internal/domain/user" +) + +// Employee represents the employee domain entity +type Employee struct { + id EmployeeID + userID user.UserID + employeeCode EmployeeCode + department Department + position Position + hireDate time.Time + salary Salary + status Status + createdAt time.Time + updatedAt time.Time +} + +// NewEmployee creates a new Employee entity with validation +func NewEmployee(userID user.UserID, employeeCode, department, position string, hireDate time.Time, salary float64, status string) (*Employee, error) { + empCode, err := NewEmployeeCode(employeeCode) + if err != nil { + return nil, err + } + + dept, err := NewDepartment(department) + if err != nil { + return nil, err + } + + pos, err := NewPosition(position) + if err != nil { + return nil, err + } + + sal, err := NewSalary(salary) + if err != nil { + return nil, err + } + + empStatus, err := NewStatus(status) + if err != nil { + return nil, err + } + + now := time.Now() + + return &Employee{ + id: GenerateEmployeeID(), + userID: userID, + employeeCode: empCode, + department: dept, + position: pos, + hireDate: hireDate, + salary: sal, + status: empStatus, + createdAt: now, + updatedAt: now, + }, nil +} + +// NewEmployeeWithID creates an Employee entity with a specific ID (for reconstruction from persistence) +func NewEmployeeWithID(id string, userID user.UserID, employeeCode, department, position string, hireDate time.Time, salary float64, status string, createdAt, updatedAt time.Time) (*Employee, error) { + empID, err := NewEmployeeID(id) + if err != nil { + return nil, err + } + + empCode, err := NewEmployeeCode(employeeCode) + if err != nil { + return nil, err + } + + dept, err := NewDepartment(department) + if err != nil { + return nil, err + } + + pos, err := NewPosition(position) + if err != nil { + return nil, err + } + + sal, err := NewSalary(salary) + if err != nil { + return nil, err + } + + empStatus, err := NewStatus(status) + if err != nil { + return nil, err + } + + return &Employee{ + id: empID, + userID: userID, + employeeCode: empCode, + department: dept, + position: pos, + hireDate: hireDate, + salary: sal, + status: empStatus, + createdAt: createdAt, + updatedAt: updatedAt, + }, nil +} + +// ID returns the employee's ID +func (e *Employee) ID() EmployeeID { + return e.id +} + +// UserID returns the employee's user ID +func (e *Employee) UserID() user.UserID { + return e.userID +} + +// EmployeeCode returns the employee's code +func (e *Employee) EmployeeCode() EmployeeCode { + return e.employeeCode +} + +// Department returns the employee's department +func (e *Employee) Department() Department { + return e.department +} + +// Position returns the employee's position +func (e *Employee) Position() Position { + return e.position +} + +// HireDate returns the employee's hire date +func (e *Employee) HireDate() time.Time { + return e.hireDate +} + +// Salary returns the employee's salary +func (e *Employee) Salary() Salary { + return e.salary +} + +// Status returns the employee's status +func (e *Employee) Status() Status { + return e.status +} + +// CreatedAt returns when the employee was created +func (e *Employee) CreatedAt() time.Time { + return e.createdAt +} + +// UpdatedAt returns when the employee was last updated +func (e *Employee) UpdatedAt() time.Time { + return e.updatedAt +} + +// UpdateEmployeeCode updates the employee's code with validation +func (e *Employee) UpdateEmployeeCode(employeeCode string) error { + empCode, err := NewEmployeeCode(employeeCode) + if err != nil { + return err + } + + e.employeeCode = empCode + e.updatedAt = time.Now() + return nil +} + +// UpdateDepartment updates the employee's department with validation +func (e *Employee) UpdateDepartment(department string) error { + dept, err := NewDepartment(department) + if err != nil { + return err + } + + e.department = dept + e.updatedAt = time.Now() + return nil +} + +// UpdatePosition updates the employee's position with validation +func (e *Employee) UpdatePosition(position string) error { + pos, err := NewPosition(position) + if err != nil { + return err + } + + e.position = pos + e.updatedAt = time.Now() + return nil +} + +// UpdateHireDate updates the employee's hire date +func (e *Employee) UpdateHireDate(hireDate time.Time) error { + if hireDate.IsZero() { + return errors.DomainError{ + Code: "INVALID_HIRE_DATE", + Message: "Hire date cannot be zero", + Field: "hireDate", + } + } + + e.hireDate = hireDate + e.updatedAt = time.Now() + return nil +} + +// UpdateSalary updates the employee's salary with validation +func (e *Employee) UpdateSalary(salary float64) error { + sal, err := NewSalary(salary) + if err != nil { + return err + } + + e.salary = sal + e.updatedAt = time.Now() + return nil +} + +// UpdateStatus updates the employee's status with validation +func (e *Employee) UpdateStatus(status string) error { + empStatus, err := NewStatus(status) + if err != nil { + return err + } + + e.status = empStatus + e.updatedAt = time.Now() + return nil +} + +// Validate performs comprehensive validation of the employee entity +func (e *Employee) Validate() error { + if e.id.String() == "" { + return errors.ErrInvalidEmployeeID + } + + if e.userID.String() == "" { + return errors.DomainError{ + Code: "INVALID_USER_ID", + Message: "User ID cannot be empty", + Field: "userID", + } + } + + if e.employeeCode.String() == "" { + return errors.ErrInvalidEmployeeCode + } + + if e.department.String() == "" { + return errors.ErrInvalidDepartment + } + + if e.position.String() == "" { + return errors.ErrInvalidPosition + } + + if e.hireDate.IsZero() { + return errors.DomainError{ + Code: "INVALID_HIRE_DATE", + Message: "Hire date cannot be zero", + Field: "hireDate", + } + } + + if e.salary.Value() <= 0 { + return errors.ErrInvalidSalary + } + + if e.status.String() == "" { + return errors.ErrInvalidStatus + } + + if e.createdAt.IsZero() { + return errors.DomainError{ + Code: "INVALID_CREATED_AT", + Message: "Created at timestamp cannot be zero", + Field: "createdAt", + } + } + + if e.updatedAt.IsZero() { + return errors.DomainError{ + Code: "INVALID_UPDATED_AT", + Message: "Updated at timestamp cannot be zero", + Field: "updatedAt", + } + } + + if e.updatedAt.Before(e.createdAt) { + return errors.DomainError{ + Code: "INVALID_TIMESTAMPS", + Message: "Updated at cannot be before created at", + Field: "updatedAt", + } + } + + return nil +} + +// Equals checks if two employees are equal based on their ID +func (e *Employee) Equals(other *Employee) bool { + if other == nil { + return false + } + return e.id.Equals(other.id) +} \ No newline at end of file diff --git a/internal/domain/employee/mocks/mock_repository.go b/internal/domain/employee/mocks/mock_repository.go new file mode 100644 index 0000000..c875d25 --- /dev/null +++ b/internal/domain/employee/mocks/mock_repository.go @@ -0,0 +1,247 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: repository.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + employee "github.com/captain-corgi/go-graphql-example/internal/domain/employee" + user "github.com/captain-corgi/go-graphql-example/internal/domain/user" + gomock "github.com/golang/mock/gomock" +) + +// MockRepository is a mock of Repository interface. +type MockRepository struct { + ctrl *gomock.Controller + recorder *MockRepositoryMockRecorder +} + +// MockRepositoryMockRecorder is the mock recorder for MockRepository. +type MockRepositoryMockRecorder struct { + mock *MockRepository +} + +// NewMockRepository creates a new mock instance. +func NewMockRepository(ctrl *gomock.Controller) *MockRepository { + mock := &MockRepository{ctrl: ctrl} + mock.recorder = &MockRepositoryMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { + return m.recorder +} + +// Count mocks base method. +func (m *MockRepository) Count(ctx context.Context) (int64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Count", ctx) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Count indicates an expected call of Count. +func (mr *MockRepositoryMockRecorder) Count(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx) +} + +// CountByDepartment mocks base method. +func (m *MockRepository) CountByDepartment(ctx context.Context, department employee.Department) (int64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CountByDepartment", ctx, department) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CountByDepartment indicates an expected call of CountByDepartment. +func (mr *MockRepositoryMockRecorder) CountByDepartment(ctx, department interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountByDepartment", reflect.TypeOf((*MockRepository)(nil).CountByDepartment), ctx, department) +} + +// CountByStatus mocks base method. +func (m *MockRepository) CountByStatus(ctx context.Context, status employee.Status) (int64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CountByStatus", ctx, status) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CountByStatus indicates an expected call of CountByStatus. +func (mr *MockRepositoryMockRecorder) CountByStatus(ctx, status interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountByStatus", reflect.TypeOf((*MockRepository)(nil).CountByStatus), ctx, status) +} + +// Create mocks base method. +func (m *MockRepository) Create(ctx context.Context, employee *employee.Employee) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Create", ctx, employee) + ret0, _ := ret[0].(error) + return ret0 +} + +// Create indicates an expected call of Create. +func (mr *MockRepositoryMockRecorder) Create(ctx, employee interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), ctx, employee) +} + +// Delete mocks base method. +func (m *MockRepository) Delete(ctx context.Context, id employee.EmployeeID) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", ctx, id) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockRepositoryMockRecorder) Delete(ctx, id interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), ctx, id) +} + +// ExistsByEmployeeCode mocks base method. +func (m *MockRepository) ExistsByEmployeeCode(ctx context.Context, employeeCode employee.EmployeeCode) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExistsByEmployeeCode", ctx, employeeCode) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ExistsByEmployeeCode indicates an expected call of ExistsByEmployeeCode. +func (mr *MockRepositoryMockRecorder) ExistsByEmployeeCode(ctx, employeeCode interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistsByEmployeeCode", reflect.TypeOf((*MockRepository)(nil).ExistsByEmployeeCode), ctx, employeeCode) +} + +// ExistsByUserID mocks base method. +func (m *MockRepository) ExistsByUserID(ctx context.Context, userID user.UserID) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ExistsByUserID", ctx, userID) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ExistsByUserID indicates an expected call of ExistsByUserID. +func (mr *MockRepositoryMockRecorder) ExistsByUserID(ctx, userID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistsByUserID", reflect.TypeOf((*MockRepository)(nil).ExistsByUserID), ctx, userID) +} + +// FindAll mocks base method. +func (m *MockRepository) FindAll(ctx context.Context, limit int, cursor string) ([]*employee.Employee, string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindAll", ctx, limit, cursor) + ret0, _ := ret[0].([]*employee.Employee) + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// FindAll indicates an expected call of FindAll. +func (mr *MockRepositoryMockRecorder) FindAll(ctx, limit, cursor interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindAll", reflect.TypeOf((*MockRepository)(nil).FindAll), ctx, limit, cursor) +} + +// FindByDepartment mocks base method. +func (m *MockRepository) FindByDepartment(ctx context.Context, department employee.Department, limit int, cursor string) ([]*employee.Employee, string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindByDepartment", ctx, department, limit, cursor) + ret0, _ := ret[0].([]*employee.Employee) + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// FindByDepartment indicates an expected call of FindByDepartment. +func (mr *MockRepositoryMockRecorder) FindByDepartment(ctx, department, limit, cursor interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByDepartment", reflect.TypeOf((*MockRepository)(nil).FindByDepartment), ctx, department, limit, cursor) +} + +// FindByEmployeeCode mocks base method. +func (m *MockRepository) FindByEmployeeCode(ctx context.Context, employeeCode employee.EmployeeCode) (*employee.Employee, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindByEmployeeCode", ctx, employeeCode) + ret0, _ := ret[0].(*employee.Employee) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindByEmployeeCode indicates an expected call of FindByEmployeeCode. +func (mr *MockRepositoryMockRecorder) FindByEmployeeCode(ctx, employeeCode interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByEmployeeCode", reflect.TypeOf((*MockRepository)(nil).FindByEmployeeCode), ctx, employeeCode) +} + +// FindByID mocks base method. +func (m *MockRepository) FindByID(ctx context.Context, id employee.EmployeeID) (*employee.Employee, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindByID", ctx, id) + ret0, _ := ret[0].(*employee.Employee) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindByID indicates an expected call of FindByID. +func (mr *MockRepositoryMockRecorder) FindByID(ctx, id interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByID", reflect.TypeOf((*MockRepository)(nil).FindByID), ctx, id) +} + +// FindByStatus mocks base method. +func (m *MockRepository) FindByStatus(ctx context.Context, status employee.Status, limit int, cursor string) ([]*employee.Employee, string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindByStatus", ctx, status, limit, cursor) + ret0, _ := ret[0].([]*employee.Employee) + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// FindByStatus indicates an expected call of FindByStatus. +func (mr *MockRepositoryMockRecorder) FindByStatus(ctx, status, limit, cursor interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByStatus", reflect.TypeOf((*MockRepository)(nil).FindByStatus), ctx, status, limit, cursor) +} + +// FindByUserID mocks base method. +func (m *MockRepository) FindByUserID(ctx context.Context, userID user.UserID) (*employee.Employee, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindByUserID", ctx, userID) + ret0, _ := ret[0].(*employee.Employee) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindByUserID indicates an expected call of FindByUserID. +func (mr *MockRepositoryMockRecorder) FindByUserID(ctx, userID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByUserID", reflect.TypeOf((*MockRepository)(nil).FindByUserID), ctx, userID) +} + +// Update mocks base method. +func (m *MockRepository) Update(ctx context.Context, employee *employee.Employee) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Update", ctx, employee) + ret0, _ := ret[0].(error) + return ret0 +} + +// Update indicates an expected call of Update. +func (mr *MockRepositoryMockRecorder) Update(ctx, employee interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), ctx, employee) +} diff --git a/internal/domain/employee/repository.go b/internal/domain/employee/repository.go new file mode 100644 index 0000000..2c40d71 --- /dev/null +++ b/internal/domain/employee/repository.go @@ -0,0 +1,57 @@ +package employee + +import ( + "context" + + "github.com/captain-corgi/go-graphql-example/internal/domain/user" +) + +//go:generate go run github.com/golang/mock/mockgen -source=$GOFILE -destination=./mocks/mock_$GOFILE -package=mocks + +// Repository defines the interface for employee persistence operations +type Repository interface { + // FindByID retrieves an employee by their ID + FindByID(ctx context.Context, id EmployeeID) (*Employee, error) + + // FindByUserID retrieves an employee by their user ID + FindByUserID(ctx context.Context, userID user.UserID) (*Employee, error) + + // FindByEmployeeCode retrieves an employee by their employee code + FindByEmployeeCode(ctx context.Context, employeeCode EmployeeCode) (*Employee, error) + + // FindAll retrieves employees with pagination support + // limit: maximum number of employees to return + // cursor: pagination cursor (empty string for first page) + // Returns employees and next cursor (empty if no more pages) + FindAll(ctx context.Context, limit int, cursor string) ([]*Employee, string, error) + + // FindByDepartment retrieves employees by department + FindByDepartment(ctx context.Context, department Department, limit int, cursor string) ([]*Employee, string, error) + + // FindByStatus retrieves employees by status + FindByStatus(ctx context.Context, status Status, limit int, cursor string) ([]*Employee, string, error) + + // Create persists a new employee + Create(ctx context.Context, employee *Employee) error + + // Update modifies an existing employee + Update(ctx context.Context, employee *Employee) error + + // Delete removes an employee by their ID + Delete(ctx context.Context, id EmployeeID) error + + // ExistsByEmployeeCode checks if an employee with the given employee code exists + ExistsByEmployeeCode(ctx context.Context, employeeCode EmployeeCode) (bool, error) + + // ExistsByUserID checks if an employee with the given user ID exists + ExistsByUserID(ctx context.Context, userID user.UserID) (bool, error) + + // Count returns the total number of employees + Count(ctx context.Context) (int64, error) + + // CountByDepartment returns the number of employees in a department + CountByDepartment(ctx context.Context, department Department) (int64, error) + + // CountByStatus returns the number of employees with a specific status + CountByStatus(ctx context.Context, status Status) (int64, error) +} \ No newline at end of file diff --git a/internal/domain/employee/value_objects.go b/internal/domain/employee/value_objects.go new file mode 100644 index 0000000..dc7ae03 --- /dev/null +++ b/internal/domain/employee/value_objects.go @@ -0,0 +1,289 @@ +package employee + +import ( + "fmt" + "regexp" + "strings" + + "github.com/captain-corgi/go-graphql-example/internal/domain/errors" + "github.com/google/uuid" +) + +// EmployeeID represents a unique identifier for an employee +type EmployeeID struct { + value string +} + +// NewEmployeeID creates a new EmployeeID from a string +func NewEmployeeID(value string) (EmployeeID, error) { + if value == "" { + return EmployeeID{}, errors.ErrInvalidEmployeeID + } + + // Validate UUID format + if _, err := uuid.Parse(value); err != nil { + return EmployeeID{}, errors.DomainError{ + Code: "INVALID_EMPLOYEE_ID_FORMAT", + Message: "Employee ID must be a valid UUID", + Field: "id", + } + } + + return EmployeeID{value: value}, nil +} + +// GenerateEmployeeID creates a new random EmployeeID +func GenerateEmployeeID() EmployeeID { + return EmployeeID{value: uuid.New().String()} +} + +// String returns the string representation of the EmployeeID +func (e EmployeeID) String() string { + return e.value +} + +// Equals checks if two EmployeeIDs are equal +func (e EmployeeID) Equals(other EmployeeID) bool { + return e.value == other.value +} + +// EmployeeCode represents an employee's unique code +type EmployeeCode struct { + value string +} + +// NewEmployeeCode creates a new EmployeeCode from a string +func NewEmployeeCode(value string) (EmployeeCode, error) { + if value == "" { + return EmployeeCode{}, errors.ErrInvalidEmployeeCode + } + + // Remove leading/trailing whitespace + value = strings.TrimSpace(value) + + // Validate length (3-10 characters) + if len(value) < 3 || len(value) > 10 { + return EmployeeCode{}, errors.DomainError{ + Code: "INVALID_EMPLOYEE_CODE_LENGTH", + Message: "Employee code must be between 3 and 10 characters", + Field: "employeeCode", + } + } + + // Validate format (alphanumeric and hyphens only) + matched, err := regexp.MatchString(`^[A-Za-z0-9-]+$`, value) + if err != nil || !matched { + return EmployeeCode{}, errors.DomainError{ + Code: "INVALID_EMPLOYEE_CODE_FORMAT", + Message: "Employee code must contain only letters, numbers, and hyphens", + Field: "employeeCode", + } + } + + return EmployeeCode{value: strings.ToUpper(value)}, nil +} + +// String returns the string representation of the EmployeeCode +func (e EmployeeCode) String() string { + return e.value +} + +// Equals checks if two EmployeeCodes are equal +func (e EmployeeCode) Equals(other EmployeeCode) bool { + return e.value == other.value +} + +// Department represents an employee's department +type Department struct { + value string +} + +// NewDepartment creates a new Department from a string +func NewDepartment(value string) (Department, error) { + if value == "" { + return Department{}, errors.ErrInvalidDepartment + } + + // Remove leading/trailing whitespace + value = strings.TrimSpace(value) + + // Validate length (2-50 characters) + if len(value) < 2 || len(value) > 50 { + return Department{}, errors.DomainError{ + Code: "INVALID_DEPARTMENT_LENGTH", + Message: "Department must be between 2 and 50 characters", + Field: "department", + } + } + + // Validate format (letters, spaces, and hyphens only) + matched, err := regexp.MatchString(`^[A-Za-z\s-]+$`, value) + if err != nil || !matched { + return Department{}, errors.DomainError{ + Code: "INVALID_DEPARTMENT_FORMAT", + Message: "Department must contain only letters, spaces, and hyphens", + Field: "department", + } + } + + return Department{value: value}, nil +} + +// String returns the string representation of the Department +func (d Department) String() string { + return d.value +} + +// Equals checks if two Departments are equal +func (d Department) Equals(other Department) bool { + return d.value == other.value +} + +// Position represents an employee's position/title +type Position struct { + value string +} + +// NewPosition creates a new Position from a string +func NewPosition(value string) (Position, error) { + if value == "" { + return Position{}, errors.ErrInvalidPosition + } + + // Remove leading/trailing whitespace + value = strings.TrimSpace(value) + + // Validate length (2-50 characters) + if len(value) < 2 || len(value) > 50 { + return Position{}, errors.DomainError{ + Code: "INVALID_POSITION_LENGTH", + Message: "Position must be between 2 and 50 characters", + Field: "position", + } + } + + // Validate format (letters, spaces, and hyphens only) + matched, err := regexp.MatchString(`^[A-Za-z\s-]+$`, value) + if err != nil || !matched { + return Position{}, errors.DomainError{ + Code: "INVALID_POSITION_FORMAT", + Message: "Position must contain only letters, spaces, and hyphens", + Field: "position", + } + } + + return Position{value: value}, nil +} + +// String returns the string representation of the Position +func (p Position) String() string { + return p.value +} + +// Equals checks if two Positions are equal +func (p Position) Equals(other Position) bool { + return p.value == other.value +} + +// Salary represents an employee's salary +type Salary struct { + value float64 +} + +// NewSalary creates a new Salary from a float64 +func NewSalary(value float64) (Salary, error) { + if value <= 0 { + return Salary{}, errors.ErrInvalidSalary + } + + // Validate maximum salary (1 million) + if value > 1000000 { + return Salary{}, errors.DomainError{ + Code: "INVALID_SALARY_RANGE", + Message: "Salary cannot exceed 1,000,000", + Field: "salary", + } + } + + return Salary{value: value}, nil +} + +// Value returns the float64 value of the Salary +func (s Salary) Value() float64 { + return s.value +} + +// Equals checks if two Salaries are equal +func (s Salary) Equals(other Salary) bool { + return s.value == other.value +} + +// String returns the string representation of the Salary +func (s Salary) String() string { + return fmt.Sprintf("%.2f", s.value) +} + +// Status represents an employee's employment status +type Status struct { + value string +} + +// Valid status values +const ( + StatusActive = "ACTIVE" + StatusInactive = "INACTIVE" + StatusTerminated = "TERMINATED" + StatusOnLeave = "ON_LEAVE" +) + +// NewStatus creates a new Status from a string +func NewStatus(value string) (Status, error) { + if value == "" { + return Status{}, errors.ErrInvalidStatus + } + + // Remove leading/trailing whitespace and convert to uppercase + value = strings.TrimSpace(strings.ToUpper(value)) + + // Validate status value + switch value { + case StatusActive, StatusInactive, StatusTerminated, StatusOnLeave: + return Status{value: value}, nil + default: + return Status{}, errors.DomainError{ + Code: "INVALID_STATUS_VALUE", + Message: fmt.Sprintf("Status must be one of: %s, %s, %s, %s", StatusActive, StatusInactive, StatusTerminated, StatusOnLeave), + Field: "status", + } + } +} + +// String returns the string representation of the Status +func (s Status) String() string { + return s.value +} + +// Equals checks if two Statuses are equal +func (s Status) Equals(other Status) bool { + return s.value == other.value +} + +// IsActive checks if the status is active +func (s Status) IsActive() bool { + return s.value == StatusActive +} + +// IsInactive checks if the status is inactive +func (s Status) IsInactive() bool { + return s.value == StatusInactive +} + +// IsTerminated checks if the status is terminated +func (s Status) IsTerminated() bool { + return s.value == StatusTerminated +} + +// IsOnLeave checks if the status is on leave +func (s Status) IsOnLeave() bool { + return s.value == StatusOnLeave +} \ No newline at end of file diff --git a/internal/domain/errors/errors.go b/internal/domain/errors/errors.go index 5d34d7f..94641e9 100644 --- a/internal/domain/errors/errors.go +++ b/internal/domain/errors/errors.go @@ -26,6 +26,19 @@ var ( ErrUserAlreadyExists = DomainError{Code: "USER_ALREADY_EXISTS", Message: "User already exists"} ) +// Employee domain errors +var ( + ErrEmployeeNotFound = DomainError{Code: "EMPLOYEE_NOT_FOUND", Message: "Employee not found"} + ErrInvalidEmployeeCode = DomainError{Code: "INVALID_EMPLOYEE_CODE", Message: "Employee code cannot be empty", Field: "employeeCode"} + ErrDuplicateEmployeeCode = DomainError{Code: "DUPLICATE_EMPLOYEE_CODE", Message: "Employee code already exists", Field: "employeeCode"} + ErrInvalidDepartment = DomainError{Code: "INVALID_DEPARTMENT", Message: "Department cannot be empty", Field: "department"} + ErrInvalidPosition = DomainError{Code: "INVALID_POSITION", Message: "Position cannot be empty", Field: "position"} + ErrInvalidSalary = DomainError{Code: "INVALID_SALARY", Message: "Salary must be greater than zero", Field: "salary"} + ErrInvalidStatus = DomainError{Code: "INVALID_STATUS", Message: "Status cannot be empty", Field: "status"} + ErrInvalidEmployeeID = DomainError{Code: "INVALID_EMPLOYEE_ID", Message: "Invalid employee ID format", Field: "id"} + ErrEmployeeAlreadyExists = DomainError{Code: "EMPLOYEE_ALREADY_EXISTS", Message: "Employee already exists"} +) + // Repository errors var ( ErrRepositoryConnection = DomainError{Code: "REPOSITORY_CONNECTION", Message: "Repository connection failed"} diff --git a/internal/infrastructure/persistence/sql/employee_repository.go b/internal/infrastructure/persistence/sql/employee_repository.go new file mode 100644 index 0000000..5da78fa --- /dev/null +++ b/internal/infrastructure/persistence/sql/employee_repository.go @@ -0,0 +1,576 @@ +package sql + +import ( + "context" + "database/sql" + "encoding/base64" + "fmt" + "time" + + "github.com/captain-corgi/go-graphql-example/internal/domain/employee" + "github.com/captain-corgi/go-graphql-example/internal/domain/errors" + "github.com/captain-corgi/go-graphql-example/internal/domain/user" +) + +// employeeRepository implements the employee.Repository interface +type employeeRepository struct { + db *sql.DB +} + +// NewEmployeeRepository creates a new employee repository +func NewEmployeeRepository(db *sql.DB) employee.Repository { + return &employeeRepository{ + db: db, + } +} + +// FindByID retrieves an employee by their ID +func (r *employeeRepository) FindByID(ctx context.Context, id employee.EmployeeID) (*employee.Employee, error) { + query := ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE id = $1 + ` + + var ( + empID, userIDStr, empCode, dept, pos, status string + hireDate time.Time + salary float64 + createdAt, updatedAt time.Time + ) + + err := r.db.QueryRowContext(ctx, query, id.String()).Scan( + &empID, &userIDStr, &empCode, &dept, &pos, &hireDate, &salary, &status, &createdAt, &updatedAt, + ) + if err != nil { + if err == sql.ErrNoRows { + return nil, errors.ErrEmployeeNotFound + } + return nil, fmt.Errorf("failed to query employee: %w", err) + } + + // Create user ID + userID, err := user.NewUserID(userIDStr) + if err != nil { + return nil, fmt.Errorf("invalid user ID in database: %w", err) + } + + // Create employee + emp, err := employee.NewEmployeeWithID(empID, userID, empCode, dept, pos, hireDate, salary, status, createdAt, updatedAt) + if err != nil { + return nil, fmt.Errorf("failed to create employee from database data: %w", err) + } + + return emp, nil +} + +// FindByUserID retrieves an employee by their user ID +func (r *employeeRepository) FindByUserID(ctx context.Context, userID user.UserID) (*employee.Employee, error) { + query := ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE user_id = $1 + ` + + var ( + empID, userIDStr, empCode, dept, pos, status string + hireDate time.Time + salary float64 + createdAt, updatedAt time.Time + ) + + err := r.db.QueryRowContext(ctx, query, userID.String()).Scan( + &empID, &userIDStr, &empCode, &dept, &pos, &hireDate, &salary, &status, &createdAt, &updatedAt, + ) + if err != nil { + if err == sql.ErrNoRows { + return nil, errors.ErrEmployeeNotFound + } + return nil, fmt.Errorf("failed to query employee by user ID: %w", err) + } + + // Create employee + emp, err := employee.NewEmployeeWithID(empID, userID, empCode, dept, pos, hireDate, salary, status, createdAt, updatedAt) + if err != nil { + return nil, fmt.Errorf("failed to create employee from database data: %w", err) + } + + return emp, nil +} + +// FindByEmployeeCode retrieves an employee by their employee code +func (r *employeeRepository) FindByEmployeeCode(ctx context.Context, employeeCode employee.EmployeeCode) (*employee.Employee, error) { + query := ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE employee_code = $1 + ` + + var ( + empID, userIDStr, empCode, dept, pos, status string + hireDate time.Time + salary float64 + createdAt, updatedAt time.Time + ) + + err := r.db.QueryRowContext(ctx, query, employeeCode.String()).Scan( + &empID, &userIDStr, &empCode, &dept, &pos, &hireDate, &salary, &status, &createdAt, &updatedAt, + ) + if err != nil { + if err == sql.ErrNoRows { + return nil, errors.ErrEmployeeNotFound + } + return nil, fmt.Errorf("failed to query employee by employee code: %w", err) + } + + // Create user ID + userID, err := user.NewUserID(userIDStr) + if err != nil { + return nil, fmt.Errorf("invalid user ID in database: %w", err) + } + + // Create employee + emp, err := employee.NewEmployeeWithID(empID, userID, empCode, dept, pos, hireDate, salary, status, createdAt, updatedAt) + if err != nil { + return nil, fmt.Errorf("failed to create employee from database data: %w", err) + } + + return emp, nil +} + +// FindAll retrieves employees with pagination support +func (r *employeeRepository) FindAll(ctx context.Context, limit int, cursor string) ([]*employee.Employee, string, error) { + var query string + var args []interface{} + + if cursor == "" { + query = ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + ORDER BY created_at ASC, id ASC + LIMIT $1 + ` + args = append(args, limit) + } else { + // Decode cursor + cursorData, err := base64.StdEncoding.DecodeString(cursor) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor format: %w", err) + } + + // Parse cursor (format: "created_at:employee_id") + var createdAtStr, empID string + _, err = fmt.Sscanf(string(cursorData), "%s:%s", &createdAtStr, &empID) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor content: %w", err) + } + + createdAt, err := time.Parse(time.RFC3339, createdAtStr) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor timestamp: %w", err) + } + + query = ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE (created_at, id) > ($1, $2) + ORDER BY created_at ASC, id ASC + LIMIT $3 + ` + args = append(args, createdAt, empID, limit) + } + + rows, err := r.db.QueryContext(ctx, query, args...) + if err != nil { + return nil, "", fmt.Errorf("failed to query employees: %w", err) + } + defer rows.Close() + + var employees []*employee.Employee + var lastCreatedAt time.Time + var lastID string + + for rows.Next() { + var ( + empID, userIDStr, empCode, dept, pos, status string + hireDate time.Time + salary float64 + createdAt, updatedAt time.Time + ) + + err := rows.Scan(&empID, &userIDStr, &empCode, &dept, &pos, &hireDate, &salary, &status, &createdAt, &updatedAt) + if err != nil { + return nil, "", fmt.Errorf("failed to scan employee row: %w", err) + } + + // Create user ID + userID, err := user.NewUserID(userIDStr) + if err != nil { + return nil, "", fmt.Errorf("invalid user ID in database: %w", err) + } + + // Create employee + emp, err := employee.NewEmployeeWithID(empID, userID, empCode, dept, pos, hireDate, salary, status, createdAt, updatedAt) + if err != nil { + return nil, "", fmt.Errorf("failed to create employee from database data: %w", err) + } + + employees = append(employees, emp) + lastCreatedAt = createdAt + lastID = empID + } + + if err = rows.Err(); err != nil { + return nil, "", fmt.Errorf("error iterating employee rows: %w", err) + } + + // Generate next cursor if we have results and reached the limit + var nextCursor string + if len(employees) == limit && len(employees) > 0 { + cursorData := fmt.Sprintf("%s:%s", lastCreatedAt.Format(time.RFC3339), lastID) + nextCursor = base64.StdEncoding.EncodeToString([]byte(cursorData)) + } + + return employees, nextCursor, nil +} + +// FindByDepartment retrieves employees by department +func (r *employeeRepository) FindByDepartment(ctx context.Context, department employee.Department, limit int, cursor string) ([]*employee.Employee, string, error) { + var query string + var args []interface{} + + if cursor == "" { + query = ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE department = $1 + ORDER BY created_at ASC, id ASC + LIMIT $2 + ` + args = append(args, department.String(), limit) + } else { + // Decode cursor + cursorData, err := base64.StdEncoding.DecodeString(cursor) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor format: %w", err) + } + + // Parse cursor (format: "created_at:employee_id") + var createdAtStr, empID string + _, err = fmt.Sscanf(string(cursorData), "%s:%s", &createdAtStr, &empID) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor content: %w", err) + } + + createdAt, err := time.Parse(time.RFC3339, createdAtStr) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor timestamp: %w", err) + } + + query = ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE department = $1 AND (created_at, id) > ($2, $3) + ORDER BY created_at ASC, id ASC + LIMIT $4 + ` + args = append(args, department.String(), createdAt, empID, limit) + } + + rows, err := r.db.QueryContext(ctx, query, args...) + if err != nil { + return nil, "", fmt.Errorf("failed to query employees by department: %w", err) + } + defer rows.Close() + + var employees []*employee.Employee + var lastCreatedAt time.Time + var lastID string + + for rows.Next() { + var ( + empID, userIDStr, empCode, dept, pos, status string + hireDate time.Time + salary float64 + createdAt, updatedAt time.Time + ) + + err := rows.Scan(&empID, &userIDStr, &empCode, &dept, &pos, &hireDate, &salary, &status, &createdAt, &updatedAt) + if err != nil { + return nil, "", fmt.Errorf("failed to scan employee row: %w", err) + } + + // Create user ID + userID, err := user.NewUserID(userIDStr) + if err != nil { + return nil, "", fmt.Errorf("invalid user ID in database: %w", err) + } + + // Create employee + emp, err := employee.NewEmployeeWithID(empID, userID, empCode, dept, pos, hireDate, salary, status, createdAt, updatedAt) + if err != nil { + return nil, "", fmt.Errorf("failed to create employee from database data: %w", err) + } + + employees = append(employees, emp) + lastCreatedAt = createdAt + lastID = empID + } + + if err = rows.Err(); err != nil { + return nil, "", fmt.Errorf("error iterating employee rows: %w", err) + } + + // Generate next cursor if we have results and reached the limit + var nextCursor string + if len(employees) == limit && len(employees) > 0 { + cursorData := fmt.Sprintf("%s:%s", lastCreatedAt.Format(time.RFC3339), lastID) + nextCursor = base64.StdEncoding.EncodeToString([]byte(cursorData)) + } + + return employees, nextCursor, nil +} + +// FindByStatus retrieves employees by status +func (r *employeeRepository) FindByStatus(ctx context.Context, status employee.Status, limit int, cursor string) ([]*employee.Employee, string, error) { + var query string + var args []interface{} + + if cursor == "" { + query = ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE status = $1 + ORDER BY created_at ASC, id ASC + LIMIT $2 + ` + args = append(args, status.String(), limit) + } else { + // Decode cursor + cursorData, err := base64.StdEncoding.DecodeString(cursor) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor format: %w", err) + } + + // Parse cursor (format: "created_at:employee_id") + var createdAtStr, empID string + _, err = fmt.Sscanf(string(cursorData), "%s:%s", &createdAtStr, &empID) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor content: %w", err) + } + + createdAt, err := time.Parse(time.RFC3339, createdAtStr) + if err != nil { + return nil, "", fmt.Errorf("invalid cursor timestamp: %w", err) + } + + query = ` + SELECT id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at + FROM employees + WHERE status = $1 AND (created_at, id) > ($2, $3) + ORDER BY created_at ASC, id ASC + LIMIT $4 + ` + args = append(args, status.String(), createdAt, empID, limit) + } + + rows, err := r.db.QueryContext(ctx, query, args...) + if err != nil { + return nil, "", fmt.Errorf("failed to query employees by status: %w", err) + } + defer rows.Close() + + var employees []*employee.Employee + var lastCreatedAt time.Time + var lastID string + + for rows.Next() { + var ( + empID, userIDStr, empCode, dept, pos, status string + hireDate time.Time + salary float64 + createdAt, updatedAt time.Time + ) + + err := rows.Scan(&empID, &userIDStr, &empCode, &dept, &pos, &hireDate, &salary, &status, &createdAt, &updatedAt) + if err != nil { + return nil, "", fmt.Errorf("failed to scan employee row: %w", err) + } + + // Create user ID + userID, err := user.NewUserID(userIDStr) + if err != nil { + return nil, "", fmt.Errorf("invalid user ID in database: %w", err) + } + + // Create employee + emp, err := employee.NewEmployeeWithID(empID, userID, empCode, dept, pos, hireDate, salary, status, createdAt, updatedAt) + if err != nil { + return nil, "", fmt.Errorf("failed to create employee from database data: %w", err) + } + + employees = append(employees, emp) + lastCreatedAt = createdAt + lastID = empID + } + + if err = rows.Err(); err != nil { + return nil, "", fmt.Errorf("error iterating employee rows: %w", err) + } + + // Generate next cursor if we have results and reached the limit + var nextCursor string + if len(employees) == limit && len(employees) > 0 { + cursorData := fmt.Sprintf("%s:%s", lastCreatedAt.Format(time.RFC3339), lastID) + nextCursor = base64.StdEncoding.EncodeToString([]byte(cursorData)) + } + + return employees, nextCursor, nil +} + +// Create persists a new employee +func (r *employeeRepository) Create(ctx context.Context, emp *employee.Employee) error { + query := ` + INSERT INTO employees (id, user_id, employee_code, department, position, hire_date, salary, status, created_at, updated_at) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) + ` + + _, err := r.db.ExecContext(ctx, query, + emp.ID().String(), + emp.UserID().String(), + emp.EmployeeCode().String(), + emp.Department().String(), + emp.Position().String(), + emp.HireDate(), + emp.Salary().Value(), + emp.Status().String(), + emp.CreatedAt(), + emp.UpdatedAt(), + ) + if err != nil { + return fmt.Errorf("failed to insert employee: %w", err) + } + + return nil +} + +// Update modifies an existing employee +func (r *employeeRepository) Update(ctx context.Context, emp *employee.Employee) error { + query := ` + UPDATE employees + SET user_id = $2, employee_code = $3, department = $4, position = $5, hire_date = $6, salary = $7, status = $8, updated_at = $9 + WHERE id = $1 + ` + + result, err := r.db.ExecContext(ctx, query, + emp.ID().String(), + emp.UserID().String(), + emp.EmployeeCode().String(), + emp.Department().String(), + emp.Position().String(), + emp.HireDate(), + emp.Salary().Value(), + emp.Status().String(), + emp.UpdatedAt(), + ) + if err != nil { + return fmt.Errorf("failed to update employee: %w", err) + } + + rowsAffected, err := result.RowsAffected() + if err != nil { + return fmt.Errorf("failed to get rows affected: %w", err) + } + + if rowsAffected == 0 { + return errors.ErrEmployeeNotFound + } + + return nil +} + +// Delete removes an employee by their ID +func (r *employeeRepository) Delete(ctx context.Context, id employee.EmployeeID) error { + query := `DELETE FROM employees WHERE id = $1` + + result, err := r.db.ExecContext(ctx, query, id.String()) + if err != nil { + return fmt.Errorf("failed to delete employee: %w", err) + } + + rowsAffected, err := result.RowsAffected() + if err != nil { + return fmt.Errorf("failed to get rows affected: %w", err) + } + + if rowsAffected == 0 { + return errors.ErrEmployeeNotFound + } + + return nil +} + +// ExistsByEmployeeCode checks if an employee with the given employee code exists +func (r *employeeRepository) ExistsByEmployeeCode(ctx context.Context, employeeCode employee.EmployeeCode) (bool, error) { + query := `SELECT EXISTS(SELECT 1 FROM employees WHERE employee_code = $1)` + + var exists bool + err := r.db.QueryRowContext(ctx, query, employeeCode.String()).Scan(&exists) + if err != nil { + return false, fmt.Errorf("failed to check if employee code exists: %w", err) + } + + return exists, nil +} + +// ExistsByUserID checks if an employee with the given user ID exists +func (r *employeeRepository) ExistsByUserID(ctx context.Context, userID user.UserID) (bool, error) { + query := `SELECT EXISTS(SELECT 1 FROM employees WHERE user_id = $1)` + + var exists bool + err := r.db.QueryRowContext(ctx, query, userID.String()).Scan(&exists) + if err != nil { + return false, fmt.Errorf("failed to check if employee exists for user: %w", err) + } + + return exists, nil +} + +// Count returns the total number of employees +func (r *employeeRepository) Count(ctx context.Context) (int64, error) { + query := `SELECT COUNT(*) FROM employees` + + var count int64 + err := r.db.QueryRowContext(ctx, query).Scan(&count) + if err != nil { + return 0, fmt.Errorf("failed to count employees: %w", err) + } + + return count, nil +} + +// CountByDepartment returns the number of employees in a department +func (r *employeeRepository) CountByDepartment(ctx context.Context, department employee.Department) (int64, error) { + query := `SELECT COUNT(*) FROM employees WHERE department = $1` + + var count int64 + err := r.db.QueryRowContext(ctx, query, department.String()).Scan(&count) + if err != nil { + return 0, fmt.Errorf("failed to count employees by department: %w", err) + } + + return count, nil +} + +// CountByStatus returns the number of employees with a specific status +func (r *employeeRepository) CountByStatus(ctx context.Context, status employee.Status) (int64, error) { + query := `SELECT COUNT(*) FROM employees WHERE status = $1` + + var count int64 + err := r.db.QueryRowContext(ctx, query, status.String()).Scan(&count) + if err != nil { + return 0, fmt.Errorf("failed to count employees by status: %w", err) + } + + return count, nil +} \ No newline at end of file diff --git a/internal/interfaces/graphql/generated/generated.go b/internal/interfaces/graphql/generated/generated.go index 67832b8..ce4340f 100644 --- a/internal/interfaces/graphql/generated/generated.go +++ b/internal/interfaces/graphql/generated/generated.go @@ -46,16 +46,49 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + CreateEmployeePayload struct { + Employee func(childComplexity int) int + Errors func(childComplexity int) int + } + CreateUserPayload struct { Errors func(childComplexity int) int User func(childComplexity int) int } + DeleteEmployeePayload struct { + Errors func(childComplexity int) int + Success func(childComplexity int) int + } + DeleteUserPayload struct { Errors func(childComplexity int) int Success func(childComplexity int) int } + Employee struct { + CreatedAt func(childComplexity int) int + Department func(childComplexity int) int + EmployeeCode func(childComplexity int) int + HireDate func(childComplexity int) int + ID func(childComplexity int) int + Position func(childComplexity int) int + Salary func(childComplexity int) int + Status func(childComplexity int) int + UpdatedAt func(childComplexity int) int + User func(childComplexity int) int + } + + EmployeeConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + } + + EmployeeEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Error struct { Code func(childComplexity int) int Field func(childComplexity int) int @@ -63,9 +96,12 @@ type ComplexityRoot struct { } Mutation struct { - CreateUser func(childComplexity int, input model.CreateUserInput) int - DeleteUser func(childComplexity int, id string) int - UpdateUser func(childComplexity int, id string, input model.UpdateUserInput) int + CreateEmployee func(childComplexity int, input model.CreateEmployeeInput) int + CreateUser func(childComplexity int, input model.CreateUserInput) int + DeleteEmployee func(childComplexity int, id string) int + DeleteUser func(childComplexity int, id string) int + UpdateEmployee func(childComplexity int, id string, input model.UpdateEmployeeInput) int + UpdateUser func(childComplexity int, id string, input model.UpdateUserInput) int } PageInfo struct { @@ -76,8 +112,17 @@ type ComplexityRoot struct { } Query struct { - User func(childComplexity int, id string) int - Users func(childComplexity int, first *int, after *string) int + Employee func(childComplexity int, id string) int + Employees func(childComplexity int, first *int, after *string) int + EmployeesByDepartment func(childComplexity int, department string, first *int, after *string) int + EmployeesByStatus func(childComplexity int, status string, first *int, after *string) int + User func(childComplexity int, id string) int + Users func(childComplexity int, first *int, after *string) int + } + + UpdateEmployeePayload struct { + Employee func(childComplexity int) int + Errors func(childComplexity int) int } UpdateUserPayload struct { @@ -108,10 +153,17 @@ type MutationResolver interface { CreateUser(ctx context.Context, input model.CreateUserInput) (*model.CreateUserPayload, error) UpdateUser(ctx context.Context, id string, input model.UpdateUserInput) (*model.UpdateUserPayload, error) DeleteUser(ctx context.Context, id string) (*model.DeleteUserPayload, error) + CreateEmployee(ctx context.Context, input model.CreateEmployeeInput) (*model.CreateEmployeePayload, error) + UpdateEmployee(ctx context.Context, id string, input model.UpdateEmployeeInput) (*model.UpdateEmployeePayload, error) + DeleteEmployee(ctx context.Context, id string) (*model.DeleteEmployeePayload, error) } type QueryResolver interface { User(ctx context.Context, id string) (*model.User, error) Users(ctx context.Context, first *int, after *string) (*model.UserConnection, error) + Employee(ctx context.Context, id string) (*model.Employee, error) + Employees(ctx context.Context, first *int, after *string) (*model.EmployeeConnection, error) + EmployeesByDepartment(ctx context.Context, department string, first *int, after *string) (*model.EmployeeConnection, error) + EmployeesByStatus(ctx context.Context, status string, first *int, after *string) (*model.EmployeeConnection, error) } type executableSchema struct { @@ -133,6 +185,20 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin _ = ec switch typeName + "." + field { + case "CreateEmployeePayload.employee": + if e.complexity.CreateEmployeePayload.Employee == nil { + break + } + + return e.complexity.CreateEmployeePayload.Employee(childComplexity), true + + case "CreateEmployeePayload.errors": + if e.complexity.CreateEmployeePayload.Errors == nil { + break + } + + return e.complexity.CreateEmployeePayload.Errors(childComplexity), true + case "CreateUserPayload.errors": if e.complexity.CreateUserPayload.Errors == nil { break @@ -147,6 +213,20 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.CreateUserPayload.User(childComplexity), true + case "DeleteEmployeePayload.errors": + if e.complexity.DeleteEmployeePayload.Errors == nil { + break + } + + return e.complexity.DeleteEmployeePayload.Errors(childComplexity), true + + case "DeleteEmployeePayload.success": + if e.complexity.DeleteEmployeePayload.Success == nil { + break + } + + return e.complexity.DeleteEmployeePayload.Success(childComplexity), true + case "DeleteUserPayload.errors": if e.complexity.DeleteUserPayload.Errors == nil { break @@ -161,6 +241,104 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.DeleteUserPayload.Success(childComplexity), true + case "Employee.createdAt": + if e.complexity.Employee.CreatedAt == nil { + break + } + + return e.complexity.Employee.CreatedAt(childComplexity), true + + case "Employee.department": + if e.complexity.Employee.Department == nil { + break + } + + return e.complexity.Employee.Department(childComplexity), true + + case "Employee.employeeCode": + if e.complexity.Employee.EmployeeCode == nil { + break + } + + return e.complexity.Employee.EmployeeCode(childComplexity), true + + case "Employee.hireDate": + if e.complexity.Employee.HireDate == nil { + break + } + + return e.complexity.Employee.HireDate(childComplexity), true + + case "Employee.id": + if e.complexity.Employee.ID == nil { + break + } + + return e.complexity.Employee.ID(childComplexity), true + + case "Employee.position": + if e.complexity.Employee.Position == nil { + break + } + + return e.complexity.Employee.Position(childComplexity), true + + case "Employee.salary": + if e.complexity.Employee.Salary == nil { + break + } + + return e.complexity.Employee.Salary(childComplexity), true + + case "Employee.status": + if e.complexity.Employee.Status == nil { + break + } + + return e.complexity.Employee.Status(childComplexity), true + + case "Employee.updatedAt": + if e.complexity.Employee.UpdatedAt == nil { + break + } + + return e.complexity.Employee.UpdatedAt(childComplexity), true + + case "Employee.user": + if e.complexity.Employee.User == nil { + break + } + + return e.complexity.Employee.User(childComplexity), true + + case "EmployeeConnection.edges": + if e.complexity.EmployeeConnection.Edges == nil { + break + } + + return e.complexity.EmployeeConnection.Edges(childComplexity), true + + case "EmployeeConnection.pageInfo": + if e.complexity.EmployeeConnection.PageInfo == nil { + break + } + + return e.complexity.EmployeeConnection.PageInfo(childComplexity), true + + case "EmployeeEdge.cursor": + if e.complexity.EmployeeEdge.Cursor == nil { + break + } + + return e.complexity.EmployeeEdge.Cursor(childComplexity), true + + case "EmployeeEdge.node": + if e.complexity.EmployeeEdge.Node == nil { + break + } + + return e.complexity.EmployeeEdge.Node(childComplexity), true + case "Error.code": if e.complexity.Error.Code == nil { break @@ -182,6 +360,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Error.Message(childComplexity), true + case "Mutation.createEmployee": + if e.complexity.Mutation.CreateEmployee == nil { + break + } + + args, err := ec.field_Mutation_createEmployee_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.CreateEmployee(childComplexity, args["input"].(model.CreateEmployeeInput)), true + case "Mutation.createUser": if e.complexity.Mutation.CreateUser == nil { break @@ -194,6 +384,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.CreateUser(childComplexity, args["input"].(model.CreateUserInput)), true + case "Mutation.deleteEmployee": + if e.complexity.Mutation.DeleteEmployee == nil { + break + } + + args, err := ec.field_Mutation_deleteEmployee_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.DeleteEmployee(childComplexity, args["id"].(string)), true + case "Mutation.deleteUser": if e.complexity.Mutation.DeleteUser == nil { break @@ -206,6 +408,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Mutation.DeleteUser(childComplexity, args["id"].(string)), true + case "Mutation.updateEmployee": + if e.complexity.Mutation.UpdateEmployee == nil { + break + } + + args, err := ec.field_Mutation_updateEmployee_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateEmployee(childComplexity, args["id"].(string), args["input"].(model.UpdateEmployeeInput)), true + case "Mutation.updateUser": if e.complexity.Mutation.UpdateUser == nil { break @@ -246,6 +460,54 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.PageInfo.StartCursor(childComplexity), true + case "Query.employee": + if e.complexity.Query.Employee == nil { + break + } + + args, err := ec.field_Query_employee_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Employee(childComplexity, args["id"].(string)), true + + case "Query.employees": + if e.complexity.Query.Employees == nil { + break + } + + args, err := ec.field_Query_employees_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Employees(childComplexity, args["first"].(*int), args["after"].(*string)), true + + case "Query.employeesByDepartment": + if e.complexity.Query.EmployeesByDepartment == nil { + break + } + + args, err := ec.field_Query_employeesByDepartment_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.EmployeesByDepartment(childComplexity, args["department"].(string), args["first"].(*int), args["after"].(*string)), true + + case "Query.employeesByStatus": + if e.complexity.Query.EmployeesByStatus == nil { + break + } + + args, err := ec.field_Query_employeesByStatus_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.EmployeesByStatus(childComplexity, args["status"].(string), args["first"].(*int), args["after"].(*string)), true + case "Query.user": if e.complexity.Query.User == nil { break @@ -270,6 +532,20 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.Query.Users(childComplexity, args["first"].(*int), args["after"].(*string)), true + case "UpdateEmployeePayload.employee": + if e.complexity.UpdateEmployeePayload.Employee == nil { + break + } + + return e.complexity.UpdateEmployeePayload.Employee(childComplexity), true + + case "UpdateEmployeePayload.errors": + if e.complexity.UpdateEmployeePayload.Errors == nil { + break + } + + return e.complexity.UpdateEmployeePayload.Errors(childComplexity), true + case "UpdateUserPayload.errors": if e.complexity.UpdateUserPayload.Errors == nil { break @@ -355,7 +631,9 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputCreateEmployeeInput, ec.unmarshalInputCreateUserInput, + ec.unmarshalInputUpdateEmployeeInput, ec.unmarshalInputUpdateUserInput, ) first := true @@ -454,19 +732,84 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ - {Name: "../../../../api/graphql/mutation.graphqls", Input: `# User mutations + {Name: "../../../../api/graphql/employee.graphqls", Input: `# Employee types and inputs + +type Employee { + id: ID! + user: User! + employeeCode: String! + department: String! + position: String! + hireDate: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented + salary: Float! + status: String! + createdAt: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented + updatedAt: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented +} + +type EmployeeConnection { + edges: [EmployeeEdge!]! + pageInfo: PageInfo! +} + +type EmployeeEdge { + node: Employee! + cursor: String! +} + +input CreateEmployeeInput { + userId: ID! + employeeCode: String! + department: String! + position: String! + hireDate: String! # TODO: Change to Time scalar when custom scalar marshaling is implemented + salary: Float! + status: String! +} + +input UpdateEmployeeInput { + employeeCode: String + department: String + position: String + hireDate: String # TODO: Change to Time scalar when custom scalar marshaling is implemented + salary: Float + status: String +} + +type CreateEmployeePayload { + employee: Employee! + errors: [Error!] +} + +type UpdateEmployeePayload { + employee: Employee! + errors: [Error!] +} + +type DeleteEmployeePayload { + success: Boolean! + errors: [Error!] +}`, BuiltIn: false}, + {Name: "../../../../api/graphql/mutation.graphqls", Input: `# User and Employee mutations type Mutation { createUser(input: CreateUserInput!): CreateUserPayload! updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload! deleteUser(id: ID!): DeleteUserPayload! + createEmployee(input: CreateEmployeeInput!): CreateEmployeePayload! + updateEmployee(id: ID!, input: UpdateEmployeeInput!): UpdateEmployeePayload! + deleteEmployee(id: ID!): DeleteEmployeePayload! } `, BuiltIn: false}, - {Name: "../../../../api/graphql/query.graphqls", Input: `# User queries + {Name: "../../../../api/graphql/query.graphqls", Input: `# User and Employee queries type Query { user(id: ID!): User users(first: Int, after: String): UserConnection! + employee(id: ID!): Employee + employees(first: Int, after: String): EmployeeConnection! + employeesByDepartment(department: String!, first: Int, after: String): EmployeeConnection! + employeesByStatus(status: String!, first: Int, after: String): EmployeeConnection! } `, BuiltIn: false}, {Name: "../../../../api/graphql/scalars.graphqls", Input: `# Custom scalar definitions @@ -539,6 +882,17 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...) // region ***************************** args.gotpl ***************************** +func (ec *executionContext) field_Mutation_createEmployee_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNCreateEmployeeInput2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateEmployeeInput) + if err != nil { + return nil, err + } + args["input"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_createUser_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -550,6 +904,17 @@ func (ec *executionContext) field_Mutation_createUser_args(ctx context.Context, return args, nil } +func (ec *executionContext) field_Mutation_deleteEmployee_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2string) + if err != nil { + return nil, err + } + args["id"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -561,6 +926,22 @@ func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, return args, nil } +func (ec *executionContext) field_Mutation_updateEmployee_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2string) + if err != nil { + return nil, err + } + args["id"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNUpdateEmployeeInput2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateEmployeeInput) + if err != nil { + return nil, err + } + args["input"] = arg1 + return args, nil +} + func (ec *executionContext) field_Mutation_updateUser_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -588,7 +969,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Query_employee_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2string) @@ -599,76 +980,145 @@ func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs m return args, nil } -func (ec *executionContext) field_Query_users_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Query_employeesByDepartment_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "department", ec.unmarshalNString2string) if err != nil { return nil, err } - args["first"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOString2ᚖstring) + args["department"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } - args["after"] = arg1 + args["first"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOString2ᚖstring) + if err != nil { + return nil, err + } + args["after"] = arg2 return args, nil } -func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Query_employeesByStatus_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool) + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "status", ec.unmarshalNString2string) if err != nil { return nil, err } - args["includeDeprecated"] = arg0 + args["status"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) + if err != nil { + return nil, err + } + args["first"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOString2ᚖstring) + if err != nil { + return nil, err + } + args["after"] = arg2 return args, nil } -func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Query_employees_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool) + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } - args["includeDeprecated"] = arg0 + args["first"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOString2ᚖstring) + if err != nil { + return nil, err + } + args["after"] = arg1 return args, nil } -func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool) + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2string) if err != nil { return nil, err } - args["includeDeprecated"] = arg0 + args["id"] = arg0 return args, nil } -func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { +func (ec *executionContext) field_Query_users_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool) + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } - args["includeDeprecated"] = arg0 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - + args["first"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOString2ᚖstring) + if err != nil { + return nil, err + } + args["after"] = arg1 + return args, nil +} + +func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool) + if err != nil { + return nil, err + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool) + if err != nil { + return nil, err + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool) + if err != nil { + return nil, err + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool) + if err != nil { + return nil, err + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** -func (ec *executionContext) _CreateUserPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.CreateUserPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CreateUserPayload_user(ctx, field) +func (ec *executionContext) _CreateEmployeePayload_employee(ctx context.Context, field graphql.CollectedField, obj *model.CreateEmployeePayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateEmployeePayload_employee(ctx, field) if err != nil { return graphql.Null } @@ -681,7 +1131,7 @@ func (ec *executionContext) _CreateUserPayload_user(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.User, nil + return obj.Employee, nil }) if err != nil { ec.Error(ctx, err) @@ -693,38 +1143,48 @@ func (ec *executionContext) _CreateUserPayload_user(ctx context.Context, field g } return graphql.Null } - res := resTmp.(*model.User) + res := resTmp.(*model.Employee) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) + return ec.marshalNEmployee2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployee(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CreateUserPayload_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CreateEmployeePayload_employee(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "CreateUserPayload", + Object: "CreateEmployeePayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) + return ec.fieldContext_Employee_id(ctx, field) + case "user": + return ec.fieldContext_Employee_user(ctx, field) + case "employeeCode": + return ec.fieldContext_Employee_employeeCode(ctx, field) + case "department": + return ec.fieldContext_Employee_department(ctx, field) + case "position": + return ec.fieldContext_Employee_position(ctx, field) + case "hireDate": + return ec.fieldContext_Employee_hireDate(ctx, field) + case "salary": + return ec.fieldContext_Employee_salary(ctx, field) + case "status": + return ec.fieldContext_Employee_status(ctx, field) case "createdAt": - return ec.fieldContext_User_createdAt(ctx, field) + return ec.fieldContext_Employee_createdAt(ctx, field) case "updatedAt": - return ec.fieldContext_User_updatedAt(ctx, field) + return ec.fieldContext_Employee_updatedAt(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Employee", field.Name) }, } return fc, nil } -func (ec *executionContext) _CreateUserPayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.CreateUserPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CreateUserPayload_errors(ctx, field) +func (ec *executionContext) _CreateEmployeePayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.CreateEmployeePayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateEmployeePayload_errors(ctx, field) if err != nil { return graphql.Null } @@ -751,9 +1211,9 @@ func (ec *executionContext) _CreateUserPayload_errors(ctx context.Context, field return ec.marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CreateUserPayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CreateEmployeePayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "CreateUserPayload", + Object: "CreateEmployeePayload", Field: field, IsMethod: false, IsResolver: false, @@ -772,8 +1232,8 @@ func (ec *executionContext) fieldContext_CreateUserPayload_errors(_ context.Cont return fc, nil } -func (ec *executionContext) _DeleteUserPayload_success(ctx context.Context, field graphql.CollectedField, obj *model.DeleteUserPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_DeleteUserPayload_success(ctx, field) +func (ec *executionContext) _CreateUserPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.CreateUserPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateUserPayload_user(ctx, field) if err != nil { return graphql.Null } @@ -786,7 +1246,7 @@ func (ec *executionContext) _DeleteUserPayload_success(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Success, nil + return obj.User, nil }) if err != nil { ec.Error(ctx, err) @@ -798,26 +1258,38 @@ func (ec *executionContext) _DeleteUserPayload_success(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*model.User) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DeleteUserPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CreateUserPayload_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "DeleteUserPayload", + Object: "CreateUserPayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "createdAt": + return ec.fieldContext_User_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_User_updatedAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _DeleteUserPayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.DeleteUserPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_DeleteUserPayload_errors(ctx, field) +func (ec *executionContext) _CreateUserPayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.CreateUserPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CreateUserPayload_errors(ctx, field) if err != nil { return graphql.Null } @@ -844,9 +1316,9 @@ func (ec *executionContext) _DeleteUserPayload_errors(ctx context.Context, field return ec.marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_DeleteUserPayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_CreateUserPayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "DeleteUserPayload", + Object: "CreateUserPayload", Field: field, IsMethod: false, IsResolver: false, @@ -865,8 +1337,8 @@ func (ec *executionContext) fieldContext_DeleteUserPayload_errors(_ context.Cont return fc, nil } -func (ec *executionContext) _Error_message(ctx context.Context, field graphql.CollectedField, obj *model.Error) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Error_message(ctx, field) +func (ec *executionContext) _DeleteEmployeePayload_success(ctx context.Context, field graphql.CollectedField, obj *model.DeleteEmployeePayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeleteEmployeePayload_success(ctx, field) if err != nil { return graphql.Null } @@ -879,7 +1351,7 @@ func (ec *executionContext) _Error_message(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Message, nil + return obj.Success, nil }) if err != nil { ec.Error(ctx, err) @@ -891,26 +1363,26 @@ func (ec *executionContext) _Error_message(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Error_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DeleteEmployeePayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Error", + Object: "DeleteEmployeePayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Error_field(ctx context.Context, field graphql.CollectedField, obj *model.Error) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Error_field(ctx, field) +func (ec *executionContext) _DeleteEmployeePayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.DeleteEmployeePayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeleteEmployeePayload_errors(ctx, field) if err != nil { return graphql.Null } @@ -923,7 +1395,7 @@ func (ec *executionContext) _Error_field(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Field, nil + return obj.Errors, nil }) if err != nil { ec.Error(ctx, err) @@ -932,26 +1404,34 @@ func (ec *executionContext) _Error_field(ctx context.Context, field graphql.Coll if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]*model.Error) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Error_field(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DeleteEmployeePayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Error", + Object: "DeleteEmployeePayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "message": + return ec.fieldContext_Error_message(ctx, field) + case "field": + return ec.fieldContext_Error_field(ctx, field) + case "code": + return ec.fieldContext_Error_code(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } -func (ec *executionContext) _Error_code(ctx context.Context, field graphql.CollectedField, obj *model.Error) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Error_code(ctx, field) +func (ec *executionContext) _DeleteUserPayload_success(ctx context.Context, field graphql.CollectedField, obj *model.DeleteUserPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeleteUserPayload_success(ctx, field) if err != nil { return graphql.Null } @@ -964,35 +1444,38 @@ func (ec *executionContext) _Error_code(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Code, nil + return obj.Success, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Error_code(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DeleteUserPayload_success(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Error", + Object: "DeleteUserPayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_createUser(ctx, field) +func (ec *executionContext) _DeleteUserPayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.DeleteUserPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DeleteUserPayload_errors(ctx, field) if err != nil { return graphql.Null } @@ -1005,55 +1488,43 @@ func (ec *executionContext) _Mutation_createUser(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateUser(rctx, fc.Args["input"].(model.CreateUserInput)) + return obj.Errors, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*model.CreateUserPayload) + res := resTmp.([]*model.Error) fc.Result = res - return ec.marshalNCreateUserPayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateUserPayload(ctx, field.Selections, res) + return ec.marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_DeleteUserPayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "DeleteUserPayload", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "user": - return ec.fieldContext_CreateUserPayload_user(ctx, field) - case "errors": - return ec.fieldContext_CreateUserPayload_errors(ctx, field) + case "message": + return ec.fieldContext_Error_message(ctx, field) + case "field": + return ec.fieldContext_Error_field(ctx, field) + case "code": + return ec.fieldContext_Error_code(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type CreateUserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) +func (ec *executionContext) _Employee_id(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_id(ctx, field) if err != nil { return graphql.Null } @@ -1066,7 +1537,7 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["id"].(string), fc.Args["input"].(model.UpdateUserInput)) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -1078,43 +1549,26 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(*model.UpdateUserPayload) + res := resTmp.(string) fc.Result = res - return ec.marshalNUpdateUserPayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateUserPayload(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Employee", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "user": - return ec.fieldContext_UpdateUserPayload_user(ctx, field) - case "errors": - return ec.fieldContext_UpdateUserPayload_errors(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UpdateUserPayload", field.Name) + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_deleteUser(ctx, field) +func (ec *executionContext) _Employee_user(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_user(ctx, field) if err != nil { return graphql.Null } @@ -1127,7 +1581,7 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteUser(rctx, fc.Args["id"].(string)) + return obj.User, nil }) if err != nil { ec.Error(ctx, err) @@ -1139,43 +1593,38 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(*model.DeleteUserPayload) + res := resTmp.(*model.User) fc.Result = res - return ec.marshalNDeleteUserPayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐDeleteUserPayload(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "Employee", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "success": - return ec.fieldContext_DeleteUserPayload_success(ctx, field) - case "errors": - return ec.fieldContext_DeleteUserPayload_errors(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "createdAt": + return ec.fieldContext_User_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_User_updatedAt(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type DeleteUserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) +func (ec *executionContext) _Employee_employeeCode(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_employeeCode(ctx, field) if err != nil { return graphql.Null } @@ -1188,7 +1637,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil + return obj.EmployeeCode, nil }) if err != nil { ec.Error(ctx, err) @@ -1200,26 +1649,26 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_employeeCode(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Employee", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) +func (ec *executionContext) _Employee_department(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_department(ctx, field) if err != nil { return graphql.Null } @@ -1232,7 +1681,7 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.HasPreviousPage, nil + return obj.Department, nil }) if err != nil { ec.Error(ctx, err) @@ -1244,26 +1693,26 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_department(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Employee", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) +func (ec *executionContext) _Employee_position(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_position(ctx, field) if err != nil { return graphql.Null } @@ -1276,23 +1725,26 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil + return obj.Position, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_position(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Employee", Field: field, IsMethod: false, IsResolver: false, @@ -1303,8 +1755,8 @@ func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) +func (ec *executionContext) _Employee_hireDate(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_hireDate(ctx, field) if err != nil { return graphql.Null } @@ -1317,23 +1769,26 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil + return obj.HireDate, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_hireDate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Employee", Field: field, IsMethod: false, IsResolver: false, @@ -1344,8 +1799,8 @@ func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, f return fc, nil } -func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_user(ctx, field) +func (ec *executionContext) _Employee_salary(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_salary(ctx, field) if err != nil { return graphql.Null } @@ -1358,58 +1813,38 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().User(rctx, fc.Args["id"].(string)) + return obj.Salary, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*model.User) + res := resTmp.(float64) fc.Result = res - return ec.marshalOUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_salary(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Employee", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "createdAt": - return ec.fieldContext_User_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_User_updatedAt(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, errors.New("field of type Float does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_users(ctx, field) +func (ec *executionContext) _Employee_status(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_status(ctx, field) if err != nil { return graphql.Null } @@ -1422,7 +1857,7 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Users(rctx, fc.Args["first"].(*int), fc.Args["after"].(*string)) + return obj.Status, nil }) if err != nil { ec.Error(ctx, err) @@ -1434,43 +1869,26 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*model.UserConnection) + res := resTmp.(string) fc.Result = res - return ec.marshalNUserConnection2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUserConnection(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Employee", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Employee_createdAt(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -1483,70 +1901,38 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Employee", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _Employee_updatedAt(ctx context.Context, field graphql.CollectedField, obj *model.Employee) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Employee_updatedAt(ctx, field) if err != nil { return graphql.Null } @@ -1559,49 +1945,38 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.UpdatedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Employee_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "Employee", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _UpdateUserPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.UpdateUserPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UpdateUserPayload_user(ctx, field) +func (ec *executionContext) _EmployeeConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.EmployeeConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmployeeConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -1614,7 +1989,7 @@ func (ec *executionContext) _UpdateUserPayload_user(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.User, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) @@ -1626,38 +2001,32 @@ func (ec *executionContext) _UpdateUserPayload_user(ctx context.Context, field g } return graphql.Null } - res := resTmp.(*model.User) + res := resTmp.([]*model.EmployeeEdge) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) + return ec.marshalNEmployeeEdge2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeEdgeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UpdateUserPayload_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_EmployeeConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UpdateUserPayload", + Object: "EmployeeConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "createdAt": - return ec.fieldContext_User_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_User_updatedAt(ctx, field) + case "node": + return ec.fieldContext_EmployeeEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_EmployeeEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type EmployeeEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _UpdateUserPayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.UpdateUserPayload) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UpdateUserPayload_errors(ctx, field) +func (ec *executionContext) _EmployeeConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.EmployeeConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmployeeConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -1670,43 +2039,48 @@ func (ec *executionContext) _UpdateUserPayload_errors(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Errors, nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*model.Error) + res := resTmp.(*model.PageInfo) fc.Result = res - return ec.marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx, field.Selections, res) + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UpdateUserPayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_EmployeeConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UpdateUserPayload", + Object: "EmployeeConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "message": - return ec.fieldContext_Error_message(ctx, field) - case "field": - return ec.fieldContext_Error_field(ctx, field) - case "code": - return ec.fieldContext_Error_code(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(ctx, field) +func (ec *executionContext) _EmployeeEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.EmployeeEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmployeeEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -1719,7 +2093,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) @@ -1731,26 +2105,48 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.Employee) fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalNEmployee2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployee(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_EmployeeEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "EmployeeEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Employee_id(ctx, field) + case "user": + return ec.fieldContext_Employee_user(ctx, field) + case "employeeCode": + return ec.fieldContext_Employee_employeeCode(ctx, field) + case "department": + return ec.fieldContext_Employee_department(ctx, field) + case "position": + return ec.fieldContext_Employee_position(ctx, field) + case "hireDate": + return ec.fieldContext_Employee_hireDate(ctx, field) + case "salary": + return ec.fieldContext_Employee_salary(ctx, field) + case "status": + return ec.fieldContext_Employee_status(ctx, field) + case "createdAt": + return ec.fieldContext_Employee_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Employee_updatedAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Employee", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_email(ctx, field) +func (ec *executionContext) _EmployeeEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.EmployeeEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_EmployeeEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -1763,7 +2159,7 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Email, nil + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) @@ -1780,9 +2176,9 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_EmployeeEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "EmployeeEdge", Field: field, IsMethod: false, IsResolver: false, @@ -1793,8 +2189,8 @@ func (ec *executionContext) fieldContext_User_email(_ context.Context, field gra return fc, nil } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_name(ctx, field) +func (ec *executionContext) _Error_message(ctx context.Context, field graphql.CollectedField, obj *model.Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_message(ctx, field) if err != nil { return graphql.Null } @@ -1807,7 +2203,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Message, nil }) if err != nil { ec.Error(ctx, err) @@ -1824,9 +2220,9 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Error_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Error", Field: field, IsMethod: false, IsResolver: false, @@ -1837,8 +2233,8 @@ func (ec *executionContext) fieldContext_User_name(_ context.Context, field grap return fc, nil } -func (ec *executionContext) _User_createdAt(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_createdAt(ctx, field) +func (ec *executionContext) _Error_field(ctx context.Context, field graphql.CollectedField, obj *model.Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_field(ctx, field) if err != nil { return graphql.Null } @@ -1851,26 +2247,23 @@ func (ec *executionContext) _User_createdAt(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.Field, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Error_field(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Error", Field: field, IsMethod: false, IsResolver: false, @@ -1881,8 +2274,8 @@ func (ec *executionContext) fieldContext_User_createdAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _User_updatedAt(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_updatedAt(ctx, field) +func (ec *executionContext) _Error_code(ctx context.Context, field graphql.CollectedField, obj *model.Error) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Error_code(ctx, field) if err != nil { return graphql.Null } @@ -1895,26 +2288,23 @@ func (ec *executionContext) _User_updatedAt(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.UpdatedAt, nil + return obj.Code, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Error_code(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "Error", Field: field, IsMethod: false, IsResolver: false, @@ -1925,8 +2315,8 @@ func (ec *executionContext) fieldContext_User_updatedAt(_ context.Context, field return fc, nil } -func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.UserConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserConnection_edges(ctx, field) +func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createUser(ctx, field) if err != nil { return graphql.Null } @@ -1939,7 +2329,7 @@ func (ec *executionContext) _UserConnection_edges(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return ec.resolvers.Mutation().CreateUser(rctx, fc.Args["input"].(model.CreateUserInput)) }) if err != nil { ec.Error(ctx, err) @@ -1951,32 +2341,43 @@ func (ec *executionContext) _UserConnection_edges(ctx context.Context, field gra } return graphql.Null } - res := resTmp.([]*model.UserEdge) + res := resTmp.(*model.CreateUserPayload) fc.Result = res - return ec.marshalNUserEdge2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUserEdgeᚄ(ctx, field.Selections, res) + return ec.marshalNCreateUserPayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateUserPayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_UserEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_UserEdge_cursor(ctx, field) + case "user": + return ec.fieldContext_CreateUserPayload_user(ctx, field) + case "errors": + return ec.fieldContext_CreateUserPayload_errors(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CreateUserPayload", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.UserConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserConnection_pageInfo(ctx, field) +func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateUser(ctx, field) if err != nil { return graphql.Null } @@ -1989,7 +2390,7 @@ func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return ec.resolvers.Mutation().UpdateUser(rctx, fc.Args["id"].(string), fc.Args["input"].(model.UpdateUserInput)) }) if err != nil { ec.Error(ctx, err) @@ -2001,36 +2402,43 @@ func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field } return graphql.Null } - res := resTmp.(*model.PageInfo) + res := resTmp.(*model.UpdateUserPayload) fc.Result = res - return ec.marshalNPageInfo2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNUpdateUserPayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateUserPayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserConnection", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "user": + return ec.fieldContext_UpdateUserPayload_user(ctx, field) + case "errors": + return ec.fieldContext_UpdateUserPayload_errors(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UpdateUserPayload", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.UserEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserEdge_node(ctx, field) +func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteUser(ctx, field) if err != nil { return graphql.Null } @@ -2043,7 +2451,7 @@ func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return ec.resolvers.Mutation().DeleteUser(rctx, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -2055,38 +2463,43 @@ func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(*model.User) + res := resTmp.(*model.DeleteUserPayload) fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) + return ec.marshalNDeleteUserPayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐDeleteUserPayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserEdge", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "email": - return ec.fieldContext_User_email(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "createdAt": - return ec.fieldContext_User_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_User_updatedAt(ctx, field) + case "success": + return ec.fieldContext_DeleteUserPayload_success(ctx, field) + case "errors": + return ec.fieldContext_DeleteUserPayload_errors(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type DeleteUserPayload", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.UserEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_UserEdge_cursor(ctx, field) +func (ec *executionContext) _Mutation_createEmployee(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_createEmployee(ctx, field) if err != nil { return graphql.Null } @@ -2099,7 +2512,7 @@ func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return ec.resolvers.Mutation().CreateEmployee(rctx, fc.Args["input"].(model.CreateEmployeeInput)) }) if err != nil { ec.Error(ctx, err) @@ -2111,26 +2524,43 @@ func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.CreateEmployeePayload) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNCreateEmployeePayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateEmployeePayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createEmployee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "UserEdge", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "employee": + return ec.fieldContext_CreateEmployeePayload_employee(ctx, field) + case "errors": + return ec.fieldContext_CreateEmployeePayload_errors(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CreateEmployeePayload", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_createEmployee_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) +func (ec *executionContext) _Mutation_updateEmployee(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_updateEmployee(ctx, field) if err != nil { return graphql.Null } @@ -2143,7 +2573,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Mutation().UpdateEmployee(rctx, fc.Args["id"].(string), fc.Args["input"].(model.UpdateEmployeeInput)) }) if err != nil { ec.Error(ctx, err) @@ -2155,26 +2585,43 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.UpdateEmployeePayload) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNUpdateEmployeePayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateEmployeePayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateEmployee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "Mutation", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "employee": + return ec.fieldContext_UpdateEmployeePayload_employee(ctx, field) + case "errors": + return ec.fieldContext_UpdateEmployeePayload_errors(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UpdateEmployeePayload", field.Name) }, } - return fc, nil -} - -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_updateEmployee_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_deleteEmployee(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_deleteEmployee(ctx, field) if err != nil { return graphql.Null } @@ -2187,35 +2634,55 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.resolvers.Mutation().DeleteEmployee(rctx, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.DeleteEmployeePayload) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNDeleteEmployeePayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐDeleteEmployeePayload(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteEmployee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "Mutation", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "success": + return ec.fieldContext_DeleteEmployeePayload_success(ctx, field) + case "errors": + return ec.fieldContext_DeleteEmployeePayload_errors(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DeleteEmployeePayload", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_deleteEmployee_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { return graphql.Null } @@ -2228,7 +2695,7 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil + return obj.HasNextPage, nil }) if err != nil { ec.Error(ctx, err) @@ -2245,9 +2712,9 @@ func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, @@ -2258,8 +2725,8 @@ func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Cont return fc, nil } -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) if err != nil { return graphql.Null } @@ -2272,7 +2739,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.HasPreviousPage, nil }) if err != nil { ec.Error(ctx, err) @@ -2284,26 +2751,26 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(bool) fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) if err != nil { return graphql.Null } @@ -2316,63 +2783,35 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.StartCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*string) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Directive", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - case "isDeprecated": - return ec.fieldContext___InputValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___InputValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) if err != nil { return graphql.Null } @@ -2385,26 +2824,23 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.EndCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, @@ -2415,8 +2851,8 @@ func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, fie return fc, nil } -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_user(ctx, field) if err != nil { return graphql.Null } @@ -2429,7 +2865,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.resolvers.Query().User(rctx, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -2438,26 +2874,49 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.User) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "createdAt": + return ec.fieldContext_User_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_User_updatedAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_users(ctx, field) if err != nil { return graphql.Null } @@ -2470,7 +2929,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return ec.resolvers.Query().Users(rctx, fc.Args["first"].(*int), fc.Args["after"].(*string)) }) if err != nil { ec.Error(ctx, err) @@ -2482,26 +2941,43 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*model.UserConnection) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNUserConnection2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUserConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_UserConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_UserConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) +func (ec *executionContext) _Query_employee(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_employee(ctx, field) if err != nil { return graphql.Null } @@ -2514,7 +2990,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return ec.resolvers.Query().Employee(rctx, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -2523,26 +2999,59 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.Employee) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOEmployee2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployee(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_employee(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__EnumValue", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Employee_id(ctx, field) + case "user": + return ec.fieldContext_Employee_user(ctx, field) + case "employeeCode": + return ec.fieldContext_Employee_employeeCode(ctx, field) + case "department": + return ec.fieldContext_Employee_department(ctx, field) + case "position": + return ec.fieldContext_Employee_position(ctx, field) + case "hireDate": + return ec.fieldContext_Employee_hireDate(ctx, field) + case "salary": + return ec.fieldContext_Employee_salary(ctx, field) + case "status": + return ec.fieldContext_Employee_status(ctx, field) + case "createdAt": + return ec.fieldContext_Employee_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Employee_updatedAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Employee", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_employee_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) +func (ec *executionContext) _Query_employees(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_employees(ctx, field) if err != nil { return graphql.Null } @@ -2555,7 +3064,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Query().Employees(rctx, fc.Args["first"].(*int), fc.Args["after"].(*string)) }) if err != nil { ec.Error(ctx, err) @@ -2567,26 +3076,43 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*model.EmployeeConnection) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNEmployeeConnection2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_employees(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_EmployeeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_EmployeeConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmployeeConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_employees_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) +func (ec *executionContext) _Query_employeesByDepartment(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_employeesByDepartment(ctx, field) if err != nil { return graphql.Null } @@ -2599,35 +3125,55 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.resolvers.Query().EmployeesByDepartment(rctx, fc.Args["department"].(string), fc.Args["first"].(*int), fc.Args["after"].(*string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.EmployeeConnection) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNEmployeeConnection2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_employeesByDepartment(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "edges": + return ec.fieldContext_EmployeeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_EmployeeConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type EmployeeConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_employeesByDepartment_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) +func (ec *executionContext) _Query_employeesByStatus(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_employeesByStatus(ctx, field) if err != nil { return graphql.Null } @@ -2640,7 +3186,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.Query().EmployeesByStatus(rctx, fc.Args["status"].(string), fc.Args["first"].(*int), fc.Args["after"].(*string)) }) if err != nil { ec.Error(ctx, err) @@ -2652,33 +3198,25 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*model.EmployeeConnection) fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) + return ec.marshalNEmployeeConnection2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_employeesByStatus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - case "isDeprecated": - return ec.fieldContext___InputValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___InputValue_deprecationReason(ctx, field) + case "edges": + return ec.fieldContext_EmployeeConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_EmployeeConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + return nil, fmt.Errorf("no field named %q was found under type EmployeeConnection", field.Name) }, } defer func() { @@ -2688,15 +3226,15 @@ func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_employeesByStatus_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -2709,28 +3247,25 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return ec.introspectType(fc.Args["name"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -2760,11 +3295,22 @@ func (ec *executionContext) fieldContext___Field_type(_ context.Context, field g return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -2777,38 +3323,49 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "Query", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) +func (ec *executionContext) _UpdateEmployeePayload_employee(ctx context.Context, field graphql.CollectedField, obj *model.UpdateEmployeePayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UpdateEmployeePayload_employee(ctx, field) if err != nil { return graphql.Null } @@ -2821,35 +3378,60 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Employee, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.Employee) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNEmployee2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployee(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UpdateEmployeePayload_employee(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Field", + Object: "UpdateEmployeePayload", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Employee_id(ctx, field) + case "user": + return ec.fieldContext_Employee_user(ctx, field) + case "employeeCode": + return ec.fieldContext_Employee_employeeCode(ctx, field) + case "department": + return ec.fieldContext_Employee_department(ctx, field) + case "position": + return ec.fieldContext_Employee_position(ctx, field) + case "hireDate": + return ec.fieldContext_Employee_hireDate(ctx, field) + case "salary": + return ec.fieldContext_Employee_salary(ctx, field) + case "status": + return ec.fieldContext_Employee_status(ctx, field) + case "createdAt": + return ec.fieldContext_Employee_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Employee_updatedAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Employee", field.Name) }, } return fc, nil } -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) +func (ec *executionContext) _UpdateEmployeePayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.UpdateEmployeePayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UpdateEmployeePayload_errors(ctx, field) if err != nil { return graphql.Null } @@ -2862,38 +3444,43 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Errors, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*model.Error) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UpdateEmployeePayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "UpdateEmployeePayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "message": + return ec.fieldContext_Error_message(ctx, field) + case "field": + return ec.fieldContext_Error_field(ctx, field) + case "code": + return ec.fieldContext_Error_code(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(ctx, field) +func (ec *executionContext) _UpdateUserPayload_user(ctx context.Context, field graphql.CollectedField, obj *model.UpdateUserPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UpdateUserPayload_user(ctx, field) if err != nil { return graphql.Null } @@ -2906,35 +3493,50 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.User, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*model.User) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UpdateUserPayload_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "UpdateUserPayload", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "createdAt": + return ec.fieldContext_User_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_User_updatedAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(ctx, field) +func (ec *executionContext) _UpdateUserPayload_errors(ctx context.Context, field graphql.CollectedField, obj *model.UpdateUserPayload) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UpdateUserPayload_errors(ctx, field) if err != nil { return graphql.Null } @@ -2947,62 +3549,43 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Errors, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]*model.Error) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UpdateUserPayload_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "UpdateUserPayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + case "message": + return ec.fieldContext_Error_message(ctx, field) + case "field": + return ec.fieldContext_Error_field(ctx, field) + case "code": + return ec.fieldContext_Error_code(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) if err != nil { return graphql.Null } @@ -3015,35 +3598,38 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_isDeprecated(ctx, field) +func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_email(ctx, field) if err != nil { return graphql.Null } @@ -3056,7 +3642,7 @@ func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Email, nil }) if err != nil { ec.Error(ctx, err) @@ -3068,26 +3654,26 @@ func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_deprecationReason(ctx, field) +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) if err != nil { return graphql.Null } @@ -3100,25 +3686,28 @@ func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__InputValue", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -3127,8 +3716,8 @@ func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ contex return fc, nil } -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(ctx, field) +func (ec *executionContext) _User_createdAt(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -3141,25 +3730,28 @@ func (ec *executionContext) ___Schema_description(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") @@ -3168,8 +3760,8 @@ func (ec *executionContext) fieldContext___Schema_description(_ context.Context, return fc, nil } -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) +func (ec *executionContext) _User_updatedAt(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_updatedAt(ctx, field) if err != nil { return graphql.Null } @@ -3182,7 +3774,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.UpdatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -3194,50 +3786,26 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_User_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "User", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(ctx, field) +func (ec *executionContext) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.UserConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -3250,7 +3818,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) @@ -3262,50 +3830,32 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]*model.UserEdge) fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNUserEdge2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUserEdgeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_queryType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "UserConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + case "node": + return ec.fieldContext_UserEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_UserEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(ctx, field) +func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.UserConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -3318,59 +3868,48 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*model.PageInfo) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_mutationType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "UserConnection", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) +func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.UserEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -3383,59 +3922,50 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.Node, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*model.User) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_subscriptionType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "UserEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "email": + return ec.fieldContext_User_email(ctx, field) case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) + return ec.fieldContext_User_name(ctx, field) + case "createdAt": + return ec.fieldContext_User_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_User_updatedAt(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) +func (ec *executionContext) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.UserEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -3448,7 +3978,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) @@ -3460,38 +3990,26 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(string) fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Schema_directives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Schema", + Object: "UserEdge", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } @@ -3504,7 +4022,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -3518,24 +4036,24 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } res := resTmp.(string) fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) if err != nil { return graphql.Null } @@ -3548,7 +4066,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) @@ -3562,9 +4080,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, IsMethod: true, IsResolver: false, @@ -3575,8 +4093,8 @@ func (ec *executionContext) fieldContext___Type_name(_ context.Context, field gr return fc, nil } -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) if err != nil { return graphql.Null } @@ -3589,35 +4107,38 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.IsRepeatable, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_isRepeatable(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) if err != nil { return graphql.Null } @@ -3630,35 +4151,38 @@ func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil + return obj.Locations, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type __DirectiveLocation does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) if err != nil { return graphql.Null } @@ -3671,42 +4195,45 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]introspection.InputValue) fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__Directive", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": - return ec.fieldContext___Field_name(ctx, field) + return ec.fieldContext___InputValue_name(ctx, field) case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) + return ec.fieldContext___InputValue_description(ctx, field) case "type": - return ec.fieldContext___Field_type(ctx, field) + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) + return ec.fieldContext___InputValue_isDeprecated(ctx, field) case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) + return ec.fieldContext___InputValue_deprecationReason(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) }, } defer func() { @@ -3716,15 +4243,15 @@ func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) if err != nil { return graphql.Null } @@ -3737,59 +4264,38 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_interfaces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) if err != nil { return graphql.Null } @@ -3802,7 +4308,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) @@ -3811,50 +4317,26 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*string) fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_possibleTypes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "isOneOf": - return ec.fieldContext___Type_isOneOf(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) if err != nil { return graphql.Null } @@ -3867,56 +4349,38 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + return obj.IsDeprecated(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "__Type", + Object: "__EnumValue", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) if err != nil { return graphql.Null } @@ -3929,7 +4393,1422 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + case "isDeprecated": + return ec.fieldContext___InputValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___InputValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "isOneOf": + return ec.fieldContext___Type_isOneOf(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil }) if err != nil { ec.Error(ctx, err) @@ -4073,41 +5952,172 @@ func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field return nil, errors.New("field of type Boolean does not have child fields") }, } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputCreateEmployeeInput(ctx context.Context, obj any) (model.CreateEmployeeInput, error) { + var it model.CreateEmployeeInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"userId", "employeeCode", "department", "position", "hireDate", "salary", "status"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "userId": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) + data, err := ec.unmarshalNID2string(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + case "employeeCode": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("employeeCode")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.EmployeeCode = data + case "department": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("department")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Department = data + case "position": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("position")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Position = data + case "hireDate": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hireDate")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.HireDate = data + case "salary": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("salary")) + data, err := ec.unmarshalNFloat2float64(ctx, v) + if err != nil { + return it, err + } + it.Salary = data + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Status = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, obj any) (model.CreateUserInput, error) { + var it model.CreateUserInput + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"email", "name"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "email": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Email = data + case "name": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + } + } -// region **************************** input.gotpl ***************************** + return it, nil +} -func (ec *executionContext) unmarshalInputCreateUserInput(ctx context.Context, obj any) (model.CreateUserInput, error) { - var it model.CreateUserInput +func (ec *executionContext) unmarshalInputUpdateEmployeeInput(ctx context.Context, obj any) (model.UpdateEmployeeInput, error) { + var it model.UpdateEmployeeInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"email", "name"} + fieldsInOrder := [...]string{"employeeCode", "department", "position", "hireDate", "salary", "status"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "email": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - data, err := ec.unmarshalNString2string(ctx, v) + case "employeeCode": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("employeeCode")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Email = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalNString2string(ctx, v) + it.EmployeeCode = data + case "department": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("department")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data + it.Department = data + case "position": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("position")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Position = data + case "hireDate": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hireDate")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HireDate = data + case "salary": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("salary")) + data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v) + if err != nil { + return it, err + } + it.Salary = data + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Status = data } } @@ -4156,6 +6166,47 @@ func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, o // region **************************** object.gotpl **************************** +var createEmployeePayloadImplementors = []string{"CreateEmployeePayload"} + +func (ec *executionContext) _CreateEmployeePayload(ctx context.Context, sel ast.SelectionSet, obj *model.CreateEmployeePayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, createEmployeePayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CreateEmployeePayload") + case "employee": + out.Values[i] = ec._CreateEmployeePayload_employee(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "errors": + out.Values[i] = ec._CreateEmployeePayload_errors(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var createUserPayloadImplementors = []string{"CreateUserPayload"} func (ec *executionContext) _CreateUserPayload(ctx context.Context, sel ast.SelectionSet, obj *model.CreateUserPayload) graphql.Marshaler { @@ -4197,6 +6248,47 @@ func (ec *executionContext) _CreateUserPayload(ctx context.Context, sel ast.Sele return out } +var deleteEmployeePayloadImplementors = []string{"DeleteEmployeePayload"} + +func (ec *executionContext) _DeleteEmployeePayload(ctx context.Context, sel ast.SelectionSet, obj *model.DeleteEmployeePayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, deleteEmployeePayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("DeleteEmployeePayload") + case "success": + out.Values[i] = ec._DeleteEmployeePayload_success(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "errors": + out.Values[i] = ec._DeleteEmployeePayload_errors(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var deleteUserPayloadImplementors = []string{"DeleteUserPayload"} func (ec *executionContext) _DeleteUserPayload(ctx context.Context, sel ast.SelectionSet, obj *model.DeleteUserPayload) graphql.Marshaler { @@ -4238,6 +6330,178 @@ func (ec *executionContext) _DeleteUserPayload(ctx context.Context, sel ast.Sele return out } +var employeeImplementors = []string{"Employee"} + +func (ec *executionContext) _Employee(ctx context.Context, sel ast.SelectionSet, obj *model.Employee) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, employeeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Employee") + case "id": + out.Values[i] = ec._Employee_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "user": + out.Values[i] = ec._Employee_user(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "employeeCode": + out.Values[i] = ec._Employee_employeeCode(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "department": + out.Values[i] = ec._Employee_department(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "position": + out.Values[i] = ec._Employee_position(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "hireDate": + out.Values[i] = ec._Employee_hireDate(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "salary": + out.Values[i] = ec._Employee_salary(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "status": + out.Values[i] = ec._Employee_status(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "createdAt": + out.Values[i] = ec._Employee_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updatedAt": + out.Values[i] = ec._Employee_updatedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var employeeConnectionImplementors = []string{"EmployeeConnection"} + +func (ec *executionContext) _EmployeeConnection(ctx context.Context, sel ast.SelectionSet, obj *model.EmployeeConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, employeeConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmployeeConnection") + case "edges": + out.Values[i] = ec._EmployeeConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._EmployeeConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var employeeEdgeImplementors = []string{"EmployeeEdge"} + +func (ec *executionContext) _EmployeeEdge(ctx context.Context, sel ast.SelectionSet, obj *model.EmployeeEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, employeeEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmployeeEdge") + case "node": + out.Values[i] = ec._EmployeeEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "cursor": + out.Values[i] = ec._EmployeeEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var errorImplementors = []string{"Error"} func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *model.Error) graphql.Marshaler { @@ -4302,21 +6566,42 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) out.Values[i] = graphql.MarshalString("Mutation") case "createUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createUser(ctx, field) + return ec._Mutation_createUser(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "updateUser": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_updateUser(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteUser": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateUser": + case "createEmployee": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateUser(ctx, field) + return ec._Mutation_createEmployee(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "deleteUser": + case "updateEmployee": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_deleteUser(ctx, field) + return ec._Mutation_updateEmployee(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "deleteEmployee": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_deleteEmployee(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -4451,6 +6736,91 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "employee": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_employee(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "employees": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_employees(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "employeesByDepartment": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_employeesByDepartment(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "employeesByStatus": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_employeesByStatus(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { @@ -4483,6 +6853,47 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return out } +var updateEmployeePayloadImplementors = []string{"UpdateEmployeePayload"} + +func (ec *executionContext) _UpdateEmployeePayload(ctx context.Context, sel ast.SelectionSet, obj *model.UpdateEmployeePayload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, updateEmployeePayloadImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("UpdateEmployeePayload") + case "employee": + out.Values[i] = ec._UpdateEmployeePayload_employee(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "errors": + out.Values[i] = ec._UpdateEmployeePayload_errors(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var updateUserPayloadImplementors = []string{"UpdateUserPayload"} func (ec *executionContext) _UpdateUserPayload(ctx context.Context, sel ast.SelectionSet, obj *model.UpdateUserPayload) graphql.Marshaler { @@ -5022,6 +7433,25 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } +func (ec *executionContext) unmarshalNCreateEmployeeInput2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateEmployeeInput(ctx context.Context, v any) (model.CreateEmployeeInput, error) { + res, err := ec.unmarshalInputCreateEmployeeInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNCreateEmployeePayload2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateEmployeePayload(ctx context.Context, sel ast.SelectionSet, v model.CreateEmployeePayload) graphql.Marshaler { + return ec._CreateEmployeePayload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNCreateEmployeePayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateEmployeePayload(ctx context.Context, sel ast.SelectionSet, v *model.CreateEmployeePayload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CreateEmployeePayload(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCreateUserInput2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐCreateUserInput(ctx context.Context, v any) (model.CreateUserInput, error) { res, err := ec.unmarshalInputCreateUserInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -5041,6 +7471,20 @@ func (ec *executionContext) marshalNCreateUserPayload2ᚖgithubᚗcomᚋcaptain return ec._CreateUserPayload(ctx, sel, v) } +func (ec *executionContext) marshalNDeleteEmployeePayload2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐDeleteEmployeePayload(ctx context.Context, sel ast.SelectionSet, v model.DeleteEmployeePayload) graphql.Marshaler { + return ec._DeleteEmployeePayload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNDeleteEmployeePayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐDeleteEmployeePayload(ctx context.Context, sel ast.SelectionSet, v *model.DeleteEmployeePayload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._DeleteEmployeePayload(ctx, sel, v) +} + func (ec *executionContext) marshalNDeleteUserPayload2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐDeleteUserPayload(ctx context.Context, sel ast.SelectionSet, v model.DeleteUserPayload) graphql.Marshaler { return ec._DeleteUserPayload(ctx, sel, &v) } @@ -5055,6 +7499,84 @@ func (ec *executionContext) marshalNDeleteUserPayload2ᚖgithubᚗcomᚋcaptain return ec._DeleteUserPayload(ctx, sel, v) } +func (ec *executionContext) marshalNEmployee2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployee(ctx context.Context, sel ast.SelectionSet, v *model.Employee) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Employee(ctx, sel, v) +} + +func (ec *executionContext) marshalNEmployeeConnection2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeConnection(ctx context.Context, sel ast.SelectionSet, v model.EmployeeConnection) graphql.Marshaler { + return ec._EmployeeConnection(ctx, sel, &v) +} + +func (ec *executionContext) marshalNEmployeeConnection2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeConnection(ctx context.Context, sel ast.SelectionSet, v *model.EmployeeConnection) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._EmployeeConnection(ctx, sel, v) +} + +func (ec *executionContext) marshalNEmployeeEdge2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.EmployeeEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNEmployeeEdge2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNEmployeeEdge2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployeeEdge(ctx context.Context, sel ast.SelectionSet, v *model.EmployeeEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._EmployeeEdge(ctx, sel, v) +} + func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐError(ctx context.Context, sel ast.SelectionSet, v *model.Error) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -5065,6 +7587,22 @@ func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgo return ec._Error(ctx, sel, v) } +func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v any) (float64, error) { + res, err := graphql.UnmarshalFloatContext(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + _ = sel + res := graphql.MarshalFloatContext(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + func (ec *executionContext) unmarshalNID2string(ctx context.Context, v any) (string, error) { res, err := graphql.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) @@ -5107,6 +7645,25 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return res } +func (ec *executionContext) unmarshalNUpdateEmployeeInput2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateEmployeeInput(ctx context.Context, v any) (model.UpdateEmployeeInput, error) { + res, err := ec.unmarshalInputUpdateEmployeeInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNUpdateEmployeePayload2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateEmployeePayload(ctx context.Context, sel ast.SelectionSet, v model.UpdateEmployeePayload) graphql.Marshaler { + return ec._UpdateEmployeePayload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNUpdateEmployeePayload2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateEmployeePayload(ctx context.Context, sel ast.SelectionSet, v *model.UpdateEmployeePayload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._UpdateEmployeePayload(ctx, sel, v) +} + func (ec *executionContext) unmarshalNUpdateUserInput2githubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐUpdateUserInput(ctx context.Context, v any) (model.UpdateUserInput, error) { res, err := ec.unmarshalInputUpdateUserInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -5487,6 +8044,13 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) marshalOEmployee2ᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐEmployee(ctx context.Context, sel ast.SelectionSet, v *model.Employee) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Employee(ctx, sel, v) +} + func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgiᚋgoᚑgraphqlᚑexampleᚋinternalᚋinterfacesᚋgraphqlᚋmodelᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Error) graphql.Marshaler { if v == nil { return graphql.Null @@ -5534,6 +8098,23 @@ func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋcaptainᚑcorgi return ret } +func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v any) (*float64, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalFloatContext(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOFloat2ᚖfloat64(ctx context.Context, sel ast.SelectionSet, v *float64) graphql.Marshaler { + if v == nil { + return graphql.Null + } + _ = sel + res := graphql.MarshalFloatContext(*v) + return graphql.WrapContextMarshaler(ctx, res) +} + func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v any) (*int, error) { if v == nil { return nil, nil diff --git a/internal/interfaces/graphql/model/models_gen.go b/internal/interfaces/graphql/model/models_gen.go index 9ddb809..b0a4b9f 100644 --- a/internal/interfaces/graphql/model/models_gen.go +++ b/internal/interfaces/graphql/model/models_gen.go @@ -2,6 +2,21 @@ package model +type CreateEmployeeInput struct { + UserID string `json:"userId"` + EmployeeCode string `json:"employeeCode"` + Department string `json:"department"` + Position string `json:"position"` + HireDate string `json:"hireDate"` + Salary float64 `json:"salary"` + Status string `json:"status"` +} + +type CreateEmployeePayload struct { + Employee *Employee `json:"employee"` + Errors []*Error `json:"errors,omitempty"` +} + type CreateUserInput struct { Email string `json:"email"` Name string `json:"name"` @@ -12,11 +27,39 @@ type CreateUserPayload struct { Errors []*Error `json:"errors,omitempty"` } +type DeleteEmployeePayload struct { + Success bool `json:"success"` + Errors []*Error `json:"errors,omitempty"` +} + type DeleteUserPayload struct { Success bool `json:"success"` Errors []*Error `json:"errors,omitempty"` } +type Employee struct { + ID string `json:"id"` + User *User `json:"user"` + EmployeeCode string `json:"employeeCode"` + Department string `json:"department"` + Position string `json:"position"` + HireDate string `json:"hireDate"` + Salary float64 `json:"salary"` + Status string `json:"status"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + +type EmployeeConnection struct { + Edges []*EmployeeEdge `json:"edges"` + PageInfo *PageInfo `json:"pageInfo"` +} + +type EmployeeEdge struct { + Node *Employee `json:"node"` + Cursor string `json:"cursor"` +} + type Error struct { Message string `json:"message"` Field *string `json:"field,omitempty"` @@ -36,6 +79,20 @@ type PageInfo struct { type Query struct { } +type UpdateEmployeeInput struct { + EmployeeCode *string `json:"employeeCode,omitempty"` + Department *string `json:"department,omitempty"` + Position *string `json:"position,omitempty"` + HireDate *string `json:"hireDate,omitempty"` + Salary *float64 `json:"salary,omitempty"` + Status *string `json:"status,omitempty"` +} + +type UpdateEmployeePayload struct { + Employee *Employee `json:"employee"` + Errors []*Error `json:"errors,omitempty"` +} + type UpdateUserInput struct { Email *string `json:"email,omitempty"` Name *string `json:"name,omitempty"` diff --git a/internal/interfaces/graphql/resolver/employee.resolvers.go b/internal/interfaces/graphql/resolver/employee.resolvers.go new file mode 100644 index 0000000..d43f2e7 --- /dev/null +++ b/internal/interfaces/graphql/resolver/employee.resolvers.go @@ -0,0 +1,418 @@ +package resolver + +import ( + "context" + "time" + + "github.com/captain-corgi/go-graphql-example/internal/application/employee" + "github.com/captain-corgi/go-graphql-example/internal/interfaces/graphql/model" +) + +// Employee is the resolver for the employee field. +func (r *queryResolver) Employee(ctx context.Context, id string) (*model.Employee, error) { + // Log operation start + r.logOperation(ctx, "Employee", map[string]interface{}{ + "id": id, + }) + + // Validate and sanitize input + sanitizedID := sanitizeString(id) + if err := r.validateInput(ctx, "Employee", func() error { + return validateEmployeeID(sanitizedID) + }); err != nil { + return nil, err + } + + // Call application service + req := employee.GetEmployeeRequest{ID: sanitizedID} + resp, err := r.employeeService.GetEmployee(ctx, req) + if err != nil { + return nil, r.handleGraphQLError(ctx, err, "Employee") + } + + // No application-level errors for GetEmployeeResponse + + // Map result to GraphQL model + result := mapEmployeeDTOToGraphQL(resp.Employee) + r.logOperationSuccess(ctx, "Employee", result) + + return result, nil +} + +// Employees is the resolver for the employees field. +func (r *queryResolver) Employees(ctx context.Context, first *int, after *string) (*model.EmployeeConnection, error) { + // Log operation start + r.logOperation(ctx, "Employees", map[string]interface{}{ + "first": first, + "after": after, + }) + + // Validate pagination parameters + if err := r.validateInput(ctx, "Employees", func() error { + return validatePaginationParams(first, after) + }); err != nil { + return nil, err + } + + // Sanitize after parameter + var sanitizedAfter string + if after != nil { + sanitizedAfter = sanitizeString(*after) + } + + // Set default first value + firstValue := 10 // Default page size + if first != nil { + firstValue = *first + } + + // Call application service + req := employee.ListEmployeesRequest{ + Limit: firstValue, + Cursor: sanitizedAfter, + } + resp, err := r.employeeService.ListEmployees(ctx, req) + if err != nil { + return nil, r.handleGraphQLError(ctx, err, "Employees") + } + + // No application-level errors for ListEmployeesResponse + + // Map result to GraphQL model + result := mapEmployeeConnectionDTOToGraphQL(resp.Employees, resp.NextCursor) + r.logOperationSuccess(ctx, "Employees", result) + + return result, nil +} + +// EmployeesByDepartment is the resolver for the employeesByDepartment field. +func (r *queryResolver) EmployeesByDepartment(ctx context.Context, department string, first *int, after *string) (*model.EmployeeConnection, error) { + // Log operation start + r.logOperation(ctx, "EmployeesByDepartment", map[string]interface{}{ + "department": department, + "first": first, + "after": after, + }) + + // Validate pagination parameters + if err := r.validateInput(ctx, "EmployeesByDepartment", func() error { + return validatePaginationParams(first, after) + }); err != nil { + return nil, err + } + + // Sanitize inputs + sanitizedDepartment := sanitizeString(department) + var sanitizedAfter string + if after != nil { + sanitizedAfter = sanitizeString(*after) + } + + // Set default first value + firstValue := 10 // Default page size + if first != nil { + firstValue = *first + } + + // Call application service + req := employee.ListEmployeesByDepartmentRequest{ + Department: sanitizedDepartment, + Limit: firstValue, + Cursor: sanitizedAfter, + } + resp, err := r.employeeService.ListEmployeesByDepartment(ctx, req) + if err != nil { + return nil, r.handleGraphQLError(ctx, err, "EmployeesByDepartment") + } + + // No application-level errors for ListEmployeesByDepartmentResponse + + // Map result to GraphQL model + result := mapEmployeeConnectionDTOToGraphQL(resp.Employees, resp.NextCursor) + r.logOperationSuccess(ctx, "EmployeesByDepartment", result) + + return result, nil +} + +// EmployeesByStatus is the resolver for the employeesByStatus field. +func (r *queryResolver) EmployeesByStatus(ctx context.Context, status string, first *int, after *string) (*model.EmployeeConnection, error) { + // Log operation start + r.logOperation(ctx, "EmployeesByStatus", map[string]interface{}{ + "status": status, + "first": first, + "after": after, + }) + + // Validate pagination parameters + if err := r.validateInput(ctx, "EmployeesByStatus", func() error { + return validatePaginationParams(first, after) + }); err != nil { + return nil, err + } + + // Sanitize inputs + sanitizedStatus := sanitizeString(status) + var sanitizedAfter string + if after != nil { + sanitizedAfter = sanitizeString(*after) + } + + // Set default first value + firstValue := 10 // Default page size + if first != nil { + firstValue = *first + } + + // Call application service + req := employee.ListEmployeesByStatusRequest{ + Status: sanitizedStatus, + Limit: firstValue, + Cursor: sanitizedAfter, + } + resp, err := r.employeeService.ListEmployeesByStatus(ctx, req) + if err != nil { + return nil, r.handleGraphQLError(ctx, err, "EmployeesByStatus") + } + + // No application-level errors for ListEmployeesByStatusResponse + + // Map result to GraphQL model + result := mapEmployeeConnectionDTOToGraphQL(resp.Employees, resp.NextCursor) + r.logOperationSuccess(ctx, "EmployeesByStatus", result) + + return result, nil +} + +// CreateEmployee is the resolver for the createEmployee field. +func (r *mutationResolver) CreateEmployee(ctx context.Context, input model.CreateEmployeeInput) (*model.CreateEmployeePayload, error) { + // Log operation start + r.logOperation(ctx, "CreateEmployee", map[string]interface{}{ + "userId": input.UserID, + "employeeCode": input.EmployeeCode, + "department": input.Department, + "position": input.Position, + "hireDate": input.HireDate, + "salary": input.Salary, + "status": input.Status, + }) + + // Validate and sanitize input + sanitizedInput := model.CreateEmployeeInput{ + UserID: sanitizeString(input.UserID), + EmployeeCode: sanitizeString(input.EmployeeCode), + Department: sanitizeString(input.Department), + Position: sanitizeString(input.Position), + HireDate: sanitizeString(input.HireDate), + Salary: input.Salary, + Status: sanitizeString(input.Status), + } + + if err := r.validateInput(ctx, "CreateEmployee", func() error { + return validateCreateEmployeeInput(sanitizedInput) + }); err != nil { + return &model.CreateEmployeePayload{ + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: err.Error(), + Code: "VALIDATION_ERROR", + })}, + }, nil + } + + // Parse hire date + hireDate, err := time.Parse("2006-01-02", sanitizedInput.HireDate) + if err != nil { + return &model.CreateEmployeePayload{ + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: "Invalid hire date format. Use YYYY-MM-DD", + Code: "INVALID_HIRE_DATE", + Field: "hireDate", + })}, + }, nil + } + + // Call application service + req := employee.CreateEmployeeRequest{ + UserID: sanitizedInput.UserID, + EmployeeCode: sanitizedInput.EmployeeCode, + Department: sanitizedInput.Department, + Position: sanitizedInput.Position, + HireDate: hireDate, + Salary: sanitizedInput.Salary, + Status: sanitizedInput.Status, + } + resp, err := r.employeeService.CreateEmployee(ctx, req) + if err != nil { + return &model.CreateEmployeePayload{ + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: "Failed to create employee", + Code: "INTERNAL_ERROR", + })}, + }, nil + } + + // Handle application-level errors + if len(resp.Errors) > 0 { + return &model.CreateEmployeePayload{ + Errors: mapEmployeeErrorDTOsToGraphQL(resp.Errors), + }, nil + } + + // Map successful result + result := &model.CreateEmployeePayload{ + Employee: mapEmployeeDTOToGraphQL(resp.Employee), + } + + r.logOperationSuccess(ctx, "CreateEmployee", result) + return result, nil +} + +// UpdateEmployee is the resolver for the updateEmployee field. +func (r *mutationResolver) UpdateEmployee(ctx context.Context, id string, input model.UpdateEmployeeInput) (*model.UpdateEmployeePayload, error) { + // Log operation start + r.logOperation(ctx, "UpdateEmployee", map[string]interface{}{ + "id": id, + "employeeCode": input.EmployeeCode, + "department": input.Department, + "position": input.Position, + "hireDate": input.HireDate, + "salary": input.Salary, + "status": input.Status, + }) + + // Validate and sanitize input + sanitizedID := sanitizeString(id) + sanitizedInput := model.UpdateEmployeeInput{ + EmployeeCode: sanitizeStringPointer(input.EmployeeCode), + Department: sanitizeStringPointer(input.Department), + Position: sanitizeStringPointer(input.Position), + HireDate: sanitizeStringPointer(input.HireDate), + Salary: input.Salary, + Status: sanitizeStringPointer(input.Status), + } + + // Validate employee ID + if err := r.validateInput(ctx, "UpdateEmployee", func() error { + return validateEmployeeID(sanitizedID) + }); err != nil { + return &model.UpdateEmployeePayload{ + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: err.Error(), + Code: "VALIDATION_ERROR", + })}, + }, nil + } + + // Validate update input + if err := r.validateInput(ctx, "UpdateEmployee", func() error { + return validateUpdateEmployeeInput(sanitizedInput) + }); err != nil { + return &model.UpdateEmployeePayload{ + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: err.Error(), + Code: "VALIDATION_ERROR", + })}, + }, nil + } + + // Parse hire date if provided + var hireDate *time.Time + if sanitizedInput.HireDate != nil { + parsedDate, err := time.Parse("2006-01-02", *sanitizedInput.HireDate) + if err != nil { + return &model.UpdateEmployeePayload{ + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: "Invalid hire date format. Use YYYY-MM-DD", + Code: "INVALID_HIRE_DATE", + Field: "hireDate", + })}, + }, nil + } + hireDate = &parsedDate + } + + // Call application service + req := employee.UpdateEmployeeRequest{ + ID: sanitizedID, + EmployeeCode: sanitizedInput.EmployeeCode, + Department: sanitizedInput.Department, + Position: sanitizedInput.Position, + HireDate: hireDate, + Salary: sanitizedInput.Salary, + Status: sanitizedInput.Status, + } + resp, err := r.employeeService.UpdateEmployee(ctx, req) + if err != nil { + return &model.UpdateEmployeePayload{ + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: "Failed to update employee", + Code: "INTERNAL_ERROR", + })}, + }, nil + } + + // Handle application-level errors + if len(resp.Errors) > 0 { + return &model.UpdateEmployeePayload{ + Errors: mapEmployeeErrorDTOsToGraphQL(resp.Errors), + }, nil + } + + // Map successful result + result := &model.UpdateEmployeePayload{ + Employee: mapEmployeeDTOToGraphQL(resp.Employee), + } + + r.logOperationSuccess(ctx, "UpdateEmployee", result) + return result, nil +} + +// DeleteEmployee is the resolver for the deleteEmployee field. +func (r *mutationResolver) DeleteEmployee(ctx context.Context, id string) (*model.DeleteEmployeePayload, error) { + // Log operation start + r.logOperation(ctx, "DeleteEmployee", map[string]interface{}{ + "id": id, + }) + + // Validate and sanitize input + sanitizedID := sanitizeString(id) + if err := r.validateInput(ctx, "DeleteEmployee", func() error { + return validateEmployeeID(sanitizedID) + }); err != nil { + return &model.DeleteEmployeePayload{ + Success: false, + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: err.Error(), + Code: "VALIDATION_ERROR", + })}, + }, nil + } + + // Call application service + req := employee.DeleteEmployeeRequest{ID: sanitizedID} + resp, err := r.employeeService.DeleteEmployee(ctx, req) + if err != nil { + return &model.DeleteEmployeePayload{ + Success: false, + Errors: []*model.Error{mapEmployeeErrorDTOToGraphQL(employee.ErrorDTO{ + Message: "Failed to delete employee", + Code: "INTERNAL_ERROR", + })}, + }, nil + } + + // Handle application-level errors + if len(resp.Errors) > 0 { + return &model.DeleteEmployeePayload{ + Success: false, + Errors: mapEmployeeErrorDTOsToGraphQL(resp.Errors), + }, nil + } + + // Map successful result + result := &model.DeleteEmployeePayload{ + Success: resp.Success, + } + + r.logOperationSuccess(ctx, "DeleteEmployee", result) + return result, nil +} \ No newline at end of file diff --git a/internal/interfaces/graphql/resolver/mapper.go b/internal/interfaces/graphql/resolver/mapper.go index a91b6a4..b5581e9 100644 --- a/internal/interfaces/graphql/resolver/mapper.go +++ b/internal/interfaces/graphql/resolver/mapper.go @@ -3,6 +3,7 @@ package resolver import ( "time" + "github.com/captain-corgi/go-graphql-example/internal/application/employee" "github.com/captain-corgi/go-graphql-example/internal/application/user" "github.com/captain-corgi/go-graphql-example/internal/interfaces/graphql/model" ) @@ -96,3 +97,103 @@ func mapUpdateUserInputToRequest(id string, input model.UpdateUserInput) user.Up Name: input.Name, } } + +// mapEmployeeDTOToGraphQL converts an EmployeeDTO to a GraphQL Employee model +func mapEmployeeDTOToGraphQL(dto *employee.EmployeeDTO) *model.Employee { + if dto == nil { + return nil + } + + var user *model.User + if dto.User != nil { + user = &model.User{ + ID: dto.User.ID, + Email: dto.User.Email, + Name: dto.User.Name, + CreatedAt: dto.User.CreatedAt.Format(time.RFC3339), + UpdatedAt: dto.User.UpdatedAt.Format(time.RFC3339), + } + } + + return &model.Employee{ + ID: dto.ID, + User: user, + EmployeeCode: dto.EmployeeCode, + Department: dto.Department, + Position: dto.Position, + HireDate: dto.HireDate.Format("2006-01-02"), + Salary: dto.Salary, + Status: dto.Status, + CreatedAt: dto.CreatedAt.Format(time.RFC3339), + UpdatedAt: dto.UpdatedAt.Format(time.RFC3339), + } +} + +// mapEmployeeConnectionDTOToGraphQL converts EmployeeDTOs to a GraphQL EmployeeConnection model +func mapEmployeeConnectionDTOToGraphQL(dtos []*employee.EmployeeDTO, nextCursor string) *model.EmployeeConnection { + if len(dtos) == 0 { + return &model.EmployeeConnection{ + Edges: []*model.EmployeeEdge{}, + PageInfo: &model.PageInfo{ + HasNextPage: false, + HasPreviousPage: false, + }, + } + } + + edges := make([]*model.EmployeeEdge, len(dtos)) + for i, dto := range dtos { + // Generate cursor for pagination + cursor := dto.CreatedAt.Format(time.RFC3339) + ":" + dto.ID + edges[i] = &model.EmployeeEdge{ + Node: mapEmployeeDTOToGraphQL(dto), + Cursor: cursor, + } + } + + // Determine if there are more pages + hasNextPage := nextCursor != "" + + return &model.EmployeeConnection{ + Edges: edges, + PageInfo: &model.PageInfo{ + HasNextPage: hasNextPage, + HasPreviousPage: false, // We don't support backward pagination for now + StartCursor: &edges[0].Cursor, + EndCursor: &edges[len(edges)-1].Cursor, + }, + } +} + +// mapEmployeeErrorDTOsToGraphQL converts Employee ErrorDTOs to GraphQL Error models +func mapEmployeeErrorDTOsToGraphQL(dtos []employee.ErrorDTO) []*model.Error { + if len(dtos) == 0 { + return nil + } + + errors := make([]*model.Error, len(dtos)) + for i, dto := range dtos { + errors[i] = mapEmployeeErrorDTOToGraphQL(dto) + } + + return errors +} + +// mapEmployeeErrorDTOToGraphQL converts an Employee ErrorDTO to a GraphQL Error model +func mapEmployeeErrorDTOToGraphQL(dto employee.ErrorDTO) *model.Error { + var field *string + if dto.Field != "" { + field = &dto.Field + } + + var code *string + if dto.Code != "" { + code = &dto.Code + } + + return &model.Error{ + Message: dto.Message, + Field: field, + Code: code, + } +} diff --git a/internal/interfaces/graphql/resolver/mutation.resolvers.go b/internal/interfaces/graphql/resolver/mutation.resolvers.go index 730c52f..35811b9 100644 --- a/internal/interfaces/graphql/resolver/mutation.resolvers.go +++ b/internal/interfaces/graphql/resolver/mutation.resolvers.go @@ -184,6 +184,8 @@ func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (*model.De return result, nil } + + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } diff --git a/internal/interfaces/graphql/resolver/query.resolvers.go b/internal/interfaces/graphql/resolver/query.resolvers.go index 4b9fc99..c95429a 100644 --- a/internal/interfaces/graphql/resolver/query.resolvers.go +++ b/internal/interfaces/graphql/resolver/query.resolvers.go @@ -110,6 +110,8 @@ func (r *queryResolver) Users(ctx context.Context, first *int, after *string) (* return result, nil } + + // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } diff --git a/internal/interfaces/graphql/resolver/resolver.go b/internal/interfaces/graphql/resolver/resolver.go index e6cc740..6a352b6 100644 --- a/internal/interfaces/graphql/resolver/resolver.go +++ b/internal/interfaces/graphql/resolver/resolver.go @@ -3,6 +3,7 @@ package resolver import ( "log/slog" + "github.com/captain-corgi/go-graphql-example/internal/application/employee" "github.com/captain-corgi/go-graphql-example/internal/application/user" ) @@ -12,14 +13,16 @@ import ( // Resolver holds the dependencies for GraphQL resolvers type Resolver struct { - userService user.Service - logger *slog.Logger + userService user.Service + employeeService employee.Service + logger *slog.Logger } // NewResolver creates a new resolver with the given dependencies -func NewResolver(userService user.Service, logger *slog.Logger) *Resolver { +func NewResolver(userService user.Service, employeeService employee.Service, logger *slog.Logger) *Resolver { return &Resolver{ - userService: userService, - logger: logger, + userService: userService, + employeeService: employeeService, + logger: logger, } } diff --git a/internal/interfaces/graphql/resolver/validation.go b/internal/interfaces/graphql/resolver/validation.go index ba9b00e..b2b21a8 100644 --- a/internal/interfaces/graphql/resolver/validation.go +++ b/internal/interfaces/graphql/resolver/validation.go @@ -107,3 +107,107 @@ func sanitizeStringPointer(s *string) *string { sanitized := sanitizeString(*s) return &sanitized } + +// validateEmployeeID validates an employee ID input +func validateEmployeeID(id string) error { + if strings.TrimSpace(id) == "" { + return errors.ErrInvalidEmployeeID + } + return nil +} + +// validateCreateEmployeeInput validates CreateEmployeeInput +func validateCreateEmployeeInput(input model.CreateEmployeeInput) error { + // Validate user ID + if strings.TrimSpace(input.UserID) == "" { + return errors.DomainError{ + Code: "INVALID_USER_ID", + Message: "User ID cannot be empty", + Field: "userId", + } + } + + // Validate employee code + if strings.TrimSpace(input.EmployeeCode) == "" { + return errors.ErrInvalidEmployeeCode + } + + // Validate department + if strings.TrimSpace(input.Department) == "" { + return errors.ErrInvalidDepartment + } + + // Validate position + if strings.TrimSpace(input.Position) == "" { + return errors.ErrInvalidPosition + } + + // Validate hire date + if strings.TrimSpace(input.HireDate) == "" { + return errors.DomainError{ + Code: "INVALID_HIRE_DATE", + Message: "Hire date cannot be empty", + Field: "hireDate", + } + } + + // Validate salary + if input.Salary <= 0 { + return errors.ErrInvalidSalary + } + + // Validate status + if strings.TrimSpace(input.Status) == "" { + return errors.ErrInvalidStatus + } + + return nil +} + +// validateUpdateEmployeeInput validates UpdateEmployeeInput +func validateUpdateEmployeeInput(input model.UpdateEmployeeInput) error { + // At least one field must be provided for update + if input.EmployeeCode == nil && input.Department == nil && input.Position == nil && + input.HireDate == nil && input.Salary == nil && input.Status == nil { + return errors.DomainError{ + Code: "NO_UPDATE_FIELDS", + Message: "At least one field must be provided for update", + } + } + + // Validate employee code if provided + if input.EmployeeCode != nil && strings.TrimSpace(*input.EmployeeCode) == "" { + return errors.ErrInvalidEmployeeCode + } + + // Validate department if provided + if input.Department != nil && strings.TrimSpace(*input.Department) == "" { + return errors.ErrInvalidDepartment + } + + // Validate position if provided + if input.Position != nil && strings.TrimSpace(*input.Position) == "" { + return errors.ErrInvalidPosition + } + + // Validate hire date if provided + if input.HireDate != nil && strings.TrimSpace(*input.HireDate) == "" { + return errors.DomainError{ + Code: "INVALID_HIRE_DATE", + Message: "Hire date cannot be empty", + Field: "hireDate", + } + } + + // Validate salary if provided + if input.Salary != nil && *input.Salary <= 0 { + return errors.ErrInvalidSalary + } + + // Validate status if provided + if input.Status != nil && strings.TrimSpace(*input.Status) == "" { + return errors.ErrInvalidStatus + } + + return nil +} diff --git a/migrations/003_create_employees_table.down.sql b/migrations/003_create_employees_table.down.sql new file mode 100644 index 0000000..b9c0c23 --- /dev/null +++ b/migrations/003_create_employees_table.down.sql @@ -0,0 +1,2 @@ +-- Drop employees table +DROP TABLE IF EXISTS employees; \ No newline at end of file diff --git a/migrations/003_create_employees_table.up.sql b/migrations/003_create_employees_table.up.sql new file mode 100644 index 0000000..786d4a0 --- /dev/null +++ b/migrations/003_create_employees_table.up.sql @@ -0,0 +1,28 @@ +-- Create employees table +CREATE TABLE employees ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, + employee_code VARCHAR(10) UNIQUE NOT NULL, + department VARCHAR(50) NOT NULL, + position VARCHAR(50) NOT NULL, + hire_date DATE NOT NULL, + salary DECIMAL(10,2) NOT NULL CHECK (salary > 0), + status VARCHAR(20) NOT NULL CHECK (status IN ('ACTIVE', 'INACTIVE', 'TERMINATED', 'ON_LEAVE')), + created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), + updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() +); + +-- Create indexes for better query performance +CREATE INDEX idx_employees_user_id ON employees(user_id); +CREATE INDEX idx_employees_employee_code ON employees(employee_code); +CREATE INDEX idx_employees_department ON employees(department); +CREATE INDEX idx_employees_status ON employees(status); +CREATE INDEX idx_employees_hire_date ON employees(hire_date); +CREATE INDEX idx_employees_created_at ON employees(created_at); +CREATE INDEX idx_employees_updated_at ON employees(updated_at); + +-- Create a trigger to automatically update the updated_at column +CREATE TRIGGER update_employees_updated_at + BEFORE UPDATE ON employees + FOR EACH ROW + EXECUTE FUNCTION update_updated_at_column(); \ No newline at end of file