Skip to main content

Overview

Catalog mutations enable creating, updating, and deleting catalog types and catalog items. These operations are authenticated and include audit trail tracking.
All mutations require authentication via the [Authorize] attribute. User information is automatically captured for audit purposes.

Catalog Type Mutations

CreateCatalogoTipo

Create a new catalog type. Mutation
mutation CreateCatalogType($catalogo: CreateCatalogoTipoDTO!) {
  createCatalogoTipo(catalogo: $catalogo) {
    id
    nombre
    codigo
    activo
    padreId
    padre {
      id
      nombre
    }
  }
}
Input Parameters
Catalog type data to create
CreateCatalogoTipoDTO Fields
nombre
string
required
Catalog type name
codigo
string
required
Catalog type code (unique identifier)
padreId
int
Parent catalog type ID (for hierarchical catalogs)
Response Fields
id
int
required
Generated catalog type ID
nombre
string
Catalog type name
codigo
string
Catalog type code
activo
boolean
required
Active status (defaults to true)
padreId
int
Parent catalog type ID
padre
CatalogoTipoDTO
Parent catalog type details
catalogos
CatalogoItemDTO[]
Child catalog items
Example
mutation {
  createCatalogoTipo(catalogo: {
    nombre: "Tipos de Gasto"
    codigo: "TIPO_GASTO"
    padreId: null
  }) {
    id
    nombre
    codigo
    activo
  }
}
Source: Schema/Catalogo/Mutation/CatalogoTipoMutation.cs:31

UpdateCatalogoTipo

Update an existing catalog type. Mutation
mutation UpdateCatalogType($catalogo: UpdateCatalogoTipoDTO!) {
  updateCatalogoTipo(catalogo: $catalogo) {
    id
    nombre
    codigo
    activo
    padreId
  }
}
Input Parameters
catalogo
UpdateCatalogoTipoDTO
required
Catalog type data to update
UpdateCatalogoTipoDTO Fields
id
int
required
Catalog type ID to update
nombre
string
New catalog type name (optional)
codigo
string
New catalog type code (optional)
padreId
int
New parent catalog type ID (optional)
activo
boolean
New active status (optional)
Response Fields
id
int
required
Catalog type ID
nombre
string
Updated catalog type name
codigo
string
Updated catalog type code
activo
boolean
required
Updated active status
catalogos
CatalogoItemDTO[]
Associated catalog items
Validation
  • Catalog type must exist (404 error if not found)
  • At least one field must be provided for update (400 error if nothing to update)
Example
mutation {
  updateCatalogoTipo(catalogo: {
    id: 5
    nombre: "Tipos de Gasto Actualizado"
    activo: true
  }) {
    id
    nombre
    activo
  }
}
Source: Schema/Catalogo/Mutation/CatalogoTipoMutation.cs:58

DeleteCatalogoTipo

Delete a catalog type. Mutation
mutation DeleteCatalogType($id: Int!) {
  deleteCatalogoTipo(id: $id) {
    id
    nombre
    codigo
  }
}
Parameters
id
int
required
Catalog type ID to delete
Response Fields
id
int
required
Deleted catalog type ID
nombre
string
Deleted catalog type name
codigo
string
Deleted catalog type code
Validation
  • Catalog type must exist (404 error if not found)
Example
mutation {
  deleteCatalogoTipo(id: 5) {
    id
    nombre
  }
}
Source: Schema/Catalogo/Mutation/CatalogoTipoMutation.cs:191

Catalog Item Mutations

CreateCatalogoItem

Create a new catalog item within a catalog type. Mutation
mutation CreateCatalogItem($catalogo: CreateCatalogoItemDTO!) {
  createCatalogoItem(catalogo: $catalogo) {
    id
    nombre
    codigo
    codigoSap
    orden
    activo
    tipoId
    padreId
    catalogoTipo {
      id
      nombre
    }
  }
}
Input Parameters
catalogo
CreateCatalogoItemDTO
required
Catalog item data to create
CreateCatalogoItemDTO Fields
nombre
string
required
Catalog item name
codigo
string
Catalog item code
codigoSap
string
SAP code for integration
orden
int
required
Display order
tipoId
int
required
Catalog type ID this item belongs to
padreId
int
Parent catalog item ID (for hierarchical items)
Response Fields
id
int
required
Generated catalog item ID
nombre
string
required
Catalog item name
codigo
string
Catalog item code
codigoSap
string
SAP code
orden
int
Display order
activo
boolean
required
Active status (defaults to true)
tipoId
int
Associated catalog type ID
catalogoTipo
CatalogoTipoDTO
Associated catalog type details
catalogoPadre
CatalogoItemDTO
Parent catalog item
catalogos
CatalogoItemDTO[]
Child catalog items
Example
mutation {
  createCatalogoItem(catalogo: {
    nombre: "Transporte"
    codigo: "TRANS"
    codigoSap: "T001"
    orden: 1
    tipoId: 5
    padreId: null
  }) {
    id
    nombre
    codigo
    codigoSap
    orden
    activo
  }
}
Source: Schema/Catalogo/Mutation/CatalogoTipoMutation.cs:95

UpdateCatalogoItem

Update an existing catalog item. Mutation
mutation UpdateCatalogItem($catalogo: UpdateCatalogoItemDTO!) {
  updateCatalogoItem(catalogo: $catalogo) {
    id
    nombre
    codigo
    codigoSap
    orden
    activo
    tipoId
    padreId
  }
}
Input Parameters
catalogo
UpdateCatalogoItemDTO
required
Catalog item data to update
UpdateCatalogoItemDTO Fields
id
int
required
Catalog item ID to update
nombre
string
New catalog item name (optional)
codigo
string
New catalog item code (optional)
codigoSap
string
New SAP code (optional)
orden
int
New display order (optional)
activo
boolean
New active status (optional)
tipoId
int
New catalog type ID (optional)
padreId
int
New parent catalog item ID (optional)
Response Fields
id
int
required
Catalog item ID
nombre
string
required
Updated catalog item name
codigo
string
Updated catalog item code
codigoSap
string
Updated SAP code
orden
int
Updated display order
activo
boolean
required
Updated active status
catalogos
CatalogoItemDTO[]
Associated child items
Validation
  • Catalog item must exist (404 error if not found)
  • At least one field must be provided for update (400 error if nothing to update)
Example
mutation {
  updateCatalogoItem(catalogo: {
    id: 15
    nombre: "Transporte Actualizado"
    orden: 2
    activo: true
  }) {
    id
    nombre
    orden
    activo
  }
}
Source: Schema/Catalogo/Mutation/CatalogoTipoMutation.cs:129

DeleteCatalogoItem

Delete a catalog item. Mutation
mutation DeleteCatalogItem($id: Int!) {
  deleteCatalogoItem(id: $id) {
    id
    nombre
    codigo
  }
}
Parameters
id
int
required
Catalog item ID to delete
Response Fields
id
int
required
Deleted catalog item ID
nombre
string
required
Deleted catalog item name
codigo
string
Deleted catalog item code
Validation
  • Catalog item must exist (404 error if not found)
Example
mutation {
  deleteCatalogoItem(id: 15) {
    id
    nombre
  }
}
Source: Schema/Catalogo/Mutation/CatalogoTipoMutation.cs:179

Error Handling

All mutations implement consistent error handling:

Not Found (404)

Returned when attempting to update or delete a catalog that doesn’t exist:
{
  "errors": [{
    "message": "Catalogo {id} no encontrado",
    "extensions": {
      "code": "NOT_FOUND"
    }
  }]
}

Bad Request (400)

Returned when no fields are provided for update:
{
  "errors": [{
    "message": "Nada que actualizar",
    "extensions": {
      "code": "BAD_REQUEST"
    }
  }]
}

Server Error (500)

Returned for unexpected errors during processing:
{
  "errors": [{
    "message": "Internal server error",
    "extensions": {
      "code": "SERVER_ERROR"
    }
  }]
}

Audit Trail

All mutations automatically capture audit information: On Create:
  • usuarioCreacion: Email of the creating user (from JWT token)
  • fechaCreacion: Current timestamp
On Update:
  • usuarioModificacion: Email of the modifying user (from JWT token)
  • fechaModificacion: Current timestamp

Authorization

All mutations require a valid JWT token with the [Authorize] attribute. The user’s email is extracted from the HTTP context for audit purposes. Example Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json