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/disable query #1365

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/fuzzy-tables-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@kubb/plugin-svelte-query": minor
"@kubb/plugin-react-query": minor
"@kubb/plugin-solid-query": minor
"@kubb/plugin-vue-query": minor
"@kubb/plugin-swr": minor
"@kubb/core": minor
---

allow to disable the generation of useQuery or createQuery hooks
14 changes: 5 additions & 9 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ const description = 'OpenAPI to TypeScript, React-Query, Zod, Faker.js, MSW and
const links: Array<{ url: string; lastmod: number | undefined }> = []

const knowledgeBaseSidebar = [
{
text: 'Overview',
link: '/knowledge-base/index',
},
{
text: 'Debugging Kubb',
link: '/knowledge-base/debugging',
},
{
text: 'Custom HTTP client',
link: '/knowledge-base/fetch',
Expand All @@ -34,6 +26,10 @@ const knowledgeBaseSidebar = [
text: 'Use of your own baseUrl',
link: '/knowledge-base/base-url',
},
{
text: 'Debugging Kubb',
link: '/knowledge-base/debugging',
},
{
text: 'Filter and sort',
link: '/knowledge-base/filter-and-sort',
Expand Down Expand Up @@ -548,7 +544,7 @@ export default defineConfig({
},
{
text: 'Knowledge base',
link: '/knowledge-base/index',
link: '/knowledge-base/fetch',
activeMatch: 'knowledge-base',
},
{
Expand Down
8 changes: 7 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ title: Changelog

# Changelog

## 3.0.0-beta.12
- [`plugin-react-query`](/plugins/plugin-react-query/): allow to disable the generation of useQuery or createQuery hooks.
- [`plugin-svelte-query`](/plugins/plugin-svelte-query/): allow to disable the generation of useQuery or createQuery hooks.
- [`plugin-vue-query`](/plugins/plugin-vue-query/): allow to disable the generation of useQuery or createQuery hooks.
- [`plugin-solid-query`](/plugins/plugin-solid-query/): allow to disable the generation of useQuery or createQuery hooks.
- [`plugin-swr`](/plugins/plugin-swr/): allow to disable the generation of useQuery or createQuery hooks.

## 3.0.0-beta.11
- [`plugin-ts`](/plugins/plugin-ts): enumType `'enum'` without export type in barrel files
- [`plugin-client`](/plugins/plugin-client): Allows you to set a custom base url for all generated calls


## 3.0.0-beta.10
- [`plugin-react-query`](/plugins/plugin-react-query/): `paramsType` with options `'inline'` and `'object'` to have control over the amount of parameters when calling one of the generated functions.
- [`plugin-svelte-query`](/plugins/plugin-svelte-query/): `paramsType` with options `'inline'` and `'object'` to have control over the amount of parameters when calling one of the generated functions.
Expand Down
8 changes: 0 additions & 8 deletions docs/knowledge-base/index.md

This file was deleted.

6 changes: 2 additions & 4 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ See [Filter And Sort](/knowledge-base/filter-and-sort).
- `dataReturnType` becomes `client.dataReturnType`
- `pathParamsType` same as in `@kubb/plugin-client`
- `parser` same as in `@kubb/plugin-client`
- `query.key` same as in `@kubb/plugin-react-query`
- `queryKey` same as in `@kubb/plugin-react-query`
- `query.methods` same as in `@kubb/plugin-react-query`
- `query.importPath` same as in `@kubb/plugin-react-query`
- `mutation.key` same as in `@kubb/plugin-react-query`
- `mutationKey` same as in `@kubb/plugin-react-query`
- `mutation.methods` same as in `@kubb/plugin-react-query`
- `mutation.importPath` same as in `@kubb/plugin-react-query`
- `paramsType` will make it possible to have one object to pass your pathParams, params, headers and data.
Expand All @@ -356,9 +356,7 @@ See [Filter And Sort](/knowledge-base/filter-and-sort).
- `dataReturnType` becomes `client.dataReturnType`
- `pathParamsType` same as in `@kubb/plugin-client`
- `parser` same as in `@kubb/plugin-client`
- `query.queryKey` becomes `query.key`
- `queryOptions` has been removed as an option
- `mutate.key` becomes `mutation.key`
- `mutate.methods` becomes `mutation.methods`
- `mutate.importPath` becomes `mutation.importPath`
- Mutations will include a generated `mutationkey`
Expand Down
32 changes: 12 additions & 20 deletions docs/plugins/plugin-react-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,27 +261,23 @@ To disable queries pass `false`.

```typescript [Query]
type Query = {
/**
* Customize the queryKey, here you can specify a suffix.
*/
key?: (key: unknown[]) => unknown[]
methods: Array<HttpMethod>
importPath?: string
} | false
```

#### query.key
#### queryKey

Customize the queryKey, here you can specify a suffix.
Customize the queryKey.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:---------------------|
| Type: | `(key: unknown[]) => unknown[]` |
| Required: | `false` |
| | |
|----------:|:----------------------------------------------------------------------------|
| Type: | `(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]` |
| Required: | `false` |

#### query.methods

Expand Down Expand Up @@ -327,27 +323,23 @@ To disable queries pass `false`.

```typescript [Query]
type Mutation = {
/**
* Customize the queryKey, here you can specify a suffix.
*/
key?: (key: unknown[]) => unknown[]
methods: Array<HttpMethod>
importPath?: string
} | false
```

#### mutation.key
#### mutationKey

Customize the mutationQuery, here you can specify a suffix.
Customize the mutationKey.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:---------------------|
| Type: | `(key: unknown[]) => unknown[]` |
| Required: | `false` |
| | |
|----------:|:----------------------------------------------------------------------------|
| Type: | `(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]` |
| Required: | `false` |

#### mutation.methods

Expand Down
30 changes: 13 additions & 17 deletions docs/plugins/plugin-solid-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ Return the name of a group based on the group name, this will be used for the fi
### parser
<!--@include: ../plugin-client/parser.md-->

#### queryKey

Customize the queryKey.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:----------------------------------------------------------------------------|
| Type: | `(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]` |
| Required: | `false` |

### query

Override some useQuery behaviours. <br/>
Expand All @@ -133,28 +146,11 @@ To disable queries pass `false`.

```typescript [Query]
type Query = {
/**
* Customize the queryKey, here you can specify a suffix.
*/
key?: (key: unknown[]) => unknown[]
methods: Array<HttpMethod>
importPath?: string
} | false
```

#### query.key

Customize the queryKey, here you can specify a suffix.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:---------------------|
| Type: | `(key: unknown[]) => unknown[]` |
| Required: | `false` |

#### query.methods

Define which HttpMethods can be used for queries
Expand Down
60 changes: 26 additions & 34 deletions docs/plugins/plugin-svelte-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ Return the name of a group based on the group name, this will be used for the fi
### parser
<!--@include: ../plugin-client/parser.md-->

#### queryKey

Customize the queryKey.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:----------------------------------------------------------------------------|
| Type: | `(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]` |
| Required: | `false` |

### query

Override some useQuery behaviours. <br/>
Expand All @@ -133,28 +146,11 @@ To disable queries pass `false`.

```typescript [Query]
type Query = {
/**
* Customize the queryKey, here you can specify a suffix.
*/
key?: (key: unknown[]) => unknown[]
methods: Array<HttpMethod>
importPath?: string
} | false
```

#### query.key

Customize the queryKey, here you can specify a suffix.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:---------------------|
| Type: | `(key: unknown[]) => unknown[]` |
| Required: | `false` |

#### query.methods

Define which HttpMethods can be used for queries
Expand All @@ -178,6 +174,19 @@ the path will be applied as is, so relative path should be based on the file bei
| Required: | `false` |
| Default: | `'@tanstack/svelte-query'` |

#### mutationKey

Customize the mutationKey.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:----------------------------------------------------------------------------|
| Type: | `(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]` |
| Required: | `false` |

### mutation

Override some useMutation behaviours. <br/>
Expand All @@ -190,28 +199,11 @@ To disable queries pass `false`.

```typescript [Query]
type Mutation = {
/**
* Customize the queryKey, here you can specify a suffix.
*/
key?: (key: unknown[]) => unknown[]
methods: Array<HttpMethod>
importPath?: string
} | false
```

#### mutation.key

Customize the mutationQuery, here you can specify a suffix.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:---------------------|
| Type: | `(key: unknown[]) => unknown[]` |
| Required: | `false` |

#### mutation.methods

Define which HttpMethods can be used for mutations
Expand Down
38 changes: 25 additions & 13 deletions docs/plugins/plugin-swr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,20 @@ Return the name of a group based on the group name, this will be used for the fi
### parser
<!--@include: ../plugin-client/parser.md-->

### query
#### queryKey

Customize the queryKey.

#### query.key
| | |
|----------:|:--------------------------------|
| Type: | `(key: unknown[]) => unknown[]` |
| Required: | `true` |
::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:----------------------------------------------------------------------------|
| Type: | `(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]` |
| Required: | `false` |

### query
#### query.methods
| | |
|----------:|:--------------------|
Expand All @@ -146,13 +151,6 @@ Return the name of a group based on the group name, this will be used for the fi

### mutation

#### mutation.key
| | |
|----------:|:--------------------------------|
| Type: | `(key: unknown[]) => unknown[]` |
| Required: | `true` |


#### mutation.methods
| | |
|----------:|:--------------------|
Expand All @@ -168,6 +166,20 @@ Return the name of a group based on the group name, this will be used for the fi
| Default: | `'swr/mutation'` |


#### mutationKey

Customize the mutationKey.

::: warning
When using a string you need to use `JSON.stringify`.
:::

| | |
|----------:|:----------------------------------------------------------------------------|
| Type: | `(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]` |
| Required: | `false` |


### include
<!--@include: ../core/include.md-->

Expand Down
Loading
Loading