Skip to content

[Idea] Automatic optimistic Updates / config based optimistic Updates #2676

@ScriptType

Description

@ScriptType

I am thinking of ways of maybe do some kinds of optimist update, maybe per config?

Something like this

export default defineConfig({
  petstore: {
    output: {
      client: 'angular-query',
      override: {
        query: {
          // Define optimistic update relationships
          optimisticUpdates: {
            createPets: {
              invalidates: ['listPets'],     // Which queries to invalidate
              strategy: 'append',             // 'append' | 'prepend' | 'upsert' | 'custom'
            },
            updatePetById: {
              invalidates: ['listPets', 'showPetById'],
              strategy: 'upsert',
              matchBy: 'petId',               // Field to match for upsert
            },
            deletePet: {
              invalidates: ['listPets'],
              strategy: 'remove',
              matchBy: 'petId',
            },
          },
        },
      },
    },
  },
});

Or maybe something more automatic if we go with something like this

optimisticUpdates: {
  enabled: true,              // Turn on auto-inference
  infer: 'route-based',       // or 'tag-based' 
  overrides: {                // Manual fixes for edge cases
    createPets: {
      invalidates: ['listPets', 'getPetStats'],  // Add non-obvious relationship
    },
    importBulkData: false,    // Disable for this operation
  },
}

The full automatic one should be pretty accurate for "basic" Crud Api´s but i guess for side-effects it wouldn't really work. Without manual Configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions