openapi-codegen icon indicating copy to clipboard operation
openapi-codegen copied to clipboard

React-query documentation

Open ANDREYDEN opened this issue 3 years ago • 7 comments

openapi-codegen relies on React Query, but there is no mention of this in the documentation. Initialy, when I was exploring this package, I had to do quite some digging to find out what setup was needed in relation to React Query. For example, this article does a great job at explaining this setup.

For newcomers it might be confusing that there are missing references to @tanstack/react-query when they initialy run the code generation. Even if they install the package, there's still configuration with QueryClient and QueryClientProvider. I propose to add these steps to the setup instructions in the docs.

ANDREYDEN avatar Oct 04 '22 14:10 ANDREYDEN

Hi @ANDREYDEN, actually it does not totally rely on React Query, (for example you can generate just types or just fetchers, or you can create your own custom generators, etc).

But I agree with you, documentation can be improved. So I created a PR for it https://github.com/fabien0102/openapi-codegen/pull/108

Can you check it? Also, if you have any suggestions and wanna contribute, you are all welcome! 👍

needim avatar Oct 04 '22 20:10 needim

@needim, sounds great, thank you for doing that! If I want to contribute, would I create PRs from #108?

ANDREYDEN avatar Oct 05 '22 00:10 ANDREYDEN

I am interested also to see an example how to use a generated mutation function (for POST) - it would be great if you could include this in your documentation, or if you know of any example.

SeanCondon avatar Oct 05 '22 13:10 SeanCondon

@SeanCondon a quick example for you:

 // definition
  const createApiKey = useUserCreateApiKeyMutation({
    onSuccess: data => {
      alert("Api Key created!")
    },
  });
<Button
  onClick={() => createApiKey.mutate({ pathParams: { id: user.id } })}
  loading={createApiKey.isLoading}
>
  Create API Key
</Button>

needim avatar Oct 05 '22 13:10 needim

Thanks @needim - that's exactly what I was looking for.

SeanCondon avatar Oct 05 '22 18:10 SeanCondon

@needim, I'm going to spend some time adding docs to #108, I'll create a small PR shortly, let me know what you think

ANDREYDEN avatar Oct 11 '22 21:10 ANDREYDEN

@ANDREYDEN thanks a lot! I'm very busy these days, so I can't contribute too often, but happy to accept PRs!

needim avatar Oct 11 '22 21:10 needim