Skip to content

Better support of queryKeys / mutationKeys #42

Description

@russell-dot-js

Right now the queryKeys & mutationKeys are generated from the "ActualOperationName" from nswag, and it looks like all the options to customize queries/mutations omit our ability to change the key

So, for example, something like this could be generated:

export function getAllUsersQueryKey(...params: any[]): QueryKey {
  return trimArrayEnd([
      'Client',
      'getAllUsers',
    ]);
}

While this might also get generated:

export function createUserMutationKey(): MutationKey {
  return trimArrayEnd([
      'Client',
      'createUser',
    ]);
}

We currently have no way, as far as I can tell, to control react-query's caching, and tell it that "createUser" changes the result of "getAllUsers". Attempting to change nswag's strategy e.g. /operationGenerationMode:MultipleClientsFromOperationId does not seem to make any difference (likely because of the usage of ActualOperationName.

Why not let devs pass in their own queryKeys, either in addition or instead of the generated ones?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions