Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Provide types and hook to set the data of a specific operation safely #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Cellule
Copy link

@Cellule Cellule commented Mar 15, 2024

Example of what this generates for my project

export type QueryDataTypes = {
  galApiControllerGetHello: undefined;
  configControllerGetOpenApi: undefined;
  workspaceControllerFindAll: WorkspaceControllerFindAllResponse;
  workspaceControllerFindOne: Schemas.WorkspaceDto;
  assetControllerFindAll: AssetControllerFindAllResponse;
  assetControllerFindOne: Schemas.HydratedAssetDto;
  eventControllerFindAllByTargetId: undefined;
  partControllerFindAll: PartControllerFindAllResponse;
  partControllerCountAll: undefined;
  partControllerFindOne: Schemas.HydratedPartDto;
 ...
 };

Then in my client code I can do the following

  const queryOperationDataSetter = useSetQueryOperationData();
  const mutation = usePartControllerUpdate();

  const handleSubmit = (body) => {
    mutation.mutate(
      {
        pathParams: { id },
        body,
      },
      {
        onSuccess: (data) => {
          queryOperationDataSetter(
            {
              operationId: "partControllerFindOne",
              path: "/api/v0/parts/{id}",
              variables: { pathParams: { id } },
            },
            data  // data must be compatible with the data type of partControllerFindOne 
          );
        },
      }
    );
  }

@fabien0102
Copy link
Owner

Thanks for the contribution but I'm sorry, I didn't get the usecase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants