getMutationCache()
This method returns a MutationCache object that provides access to mutation cache operations
for the specific endpoint. The returned object has find() and findAll() methods
to search for mutations in the cache.
const mutationCache = qraft.<service>.<operation>.getMutationCache()
MutationCache.find(...)โ
Finds the first mutation that matches the specified filters.
const mutation = qraft.<service>.<operation>.getMutationCache().find(
  filters
)
Argumentsโ
filters: MutationFilters,- Optional, represents the Mutation Filters ๐ด to be used, strictly-typed โจ
 filters.parameters: { path, query, header }will be used for filtering mutations by parametersfilters.mutationKey: MutationKeywill be used for filtering mutations by MutationKey instead of parametersfilters.mutationKeyandfilters.parametersare mutually exclusive
filters.predicate?: (mutation: Mutation) => booleanwill be used for filtering mutations by custom predicatefilters.exact?: booleanwill be used for exact or partial matching of parameters (default:true)- Note: When no 
filtersare provided, the method uses the base mutation key for<service>.<operation>and automatically setsexact: falseto match all mutations for the endpoint 
Returnsโ
mutation: Mutation | undefined: The first mutation that matches the filters, or undefined if no match is found
MutationCache.findAll(...)โ
Finds all mutations that match the specified filters.
- With 
filters - Without 
filters 
Finds all mutations with the specified filters.
const mutations = qraft.<service>.<operation>.getMutationCache().findAll(
  filters
)
Argumentsโ
filters: MutationFilters,- Optional, represents the Mutation Filters ๐ด to be used, strictly-typed โจ
 filters.parameters: { path, query, header }will be used for filtering mutations by parametersfilters.mutationKey: MutationKeywill be used for filtering mutations by MutationKey instead of parametersfilters.mutationKeyandfilters.parametersare mutually exclusive
filters.predicate?: (mutation: Mutation) => booleanwill be used for filtering mutations by custom predicatefilters.exact?: booleanwill be used for exact or partial matching of parameters (default:true)- Note: When no 
filtersare provided, the method uses the base mutation key for<service>.<operation>and automatically setsexact: falseto match all mutations for the endpoint 
Returnsโ
mutations: Mutation[]: Array of all mutations that match the filters
Finds all mutations for the specified endpoint.
const mutations = qraft.<service>.<operation>.getMutationCache().findAll()
Returnsโ
mutations: Mutation[]: Array of all mutations matching <service>.<operation>
Examplesโ
find()with parametersfind()with mutation keyfind()with partial parametersfind()with predicatefindAll()without filters
Find a mutation with specific parameters:
/**
 * Find the mutation with the specified parameters:
 * ###
 * POST /entities/3e3e-3e3e-3e3e/documents
 * x-version: 2023-09-01
 **/
const mutationCache = qraft.entities.postEntitiesIdDocuments.getMutationCache();
const mutation = mutationCache.find({
  parameters: {
    header: {
      'x-version': '2023-09-01',
    },
    path: {
      entity_id: '3e3e-3e3e-3e3e',
    },
  },
});
if (mutation) {
  console.log('Mutation found:', mutation.state.data);
}
Find a mutation using mutation key:
const mutationCache = qraft.entities.postEntitiesIdDocuments.getMutationCache();
const mutationKey = qraft.entities.postEntitiesIdDocuments.getMutationKey({
  header: {
    'x-version': '2023-09-01',
  },
  path: {
    entity_id: '3e3e-3e3e-3e3e',
  },
});
const mutation = mutationCache.find({
  mutationKey,
});
if (mutation) {
  console.log('Mutation found:', mutation.state.data);
}
Find a mutation with partial parameters (non-exact matching):
/**
 * Find mutations that match only header parameters:
 * ###
 * POST /entities/{id}/documents
 * x-version: 2023-09-01
 **/
const mutationCache = qraft.entities.postEntitiesIdDocuments.getMutationCache();
const mutation = mutationCache.find({
  exact: false,
  parameters: {
    header: {
      'x-version': '2023-09-01',
    },
  },
});
if (mutation) {
  console.log('Mutation found with matching header:', mutation.state.data);
}
Find a mutation using custom predicate:
const mutationCache = qraft.entities.postEntitiesIdDocuments.getMutationCache();
const mutation = mutationCache.find({
  predicate: (mutation) => {
    return mutation.state.data?.header?.['x-version'] === '2023-09-01';
  },
});
if (mutation) {
  console.log('Mutation found with predicate:', mutation.state.data);
}
Find all mutations for the endpoint:
/**
 * Find all mutations for the endpoint:
 * ###
 * POST /entities/3e3e-3e3e-3e3e/documents
 * x-version: 2023-09-01
 * ###
 * POST /entities/4c4c-4c4c-4c4c/documents
 * x-version: 2023-09-01
 * ###
 * โฌ๏ธ All mutations for the specified endpoint will be returned
 **/
const mutationCache = qraft.entities.postEntitiesIdDocuments.getMutationCache();
const mutations = mutationCache.findAll();
console.log(`Found ${mutations.length} mutations`);
mutations.forEach((mutation, index) => {
  console.log(`Mutation ${index + 1}:`, mutation.state.data);
});