Skip to content

Commit 06e8f32

Browse files
authored
Merge pull request #1079 from Shrugsy/docs/restructure-rtkq-docs-organisation
Docs - restructure rtk-query docs organisation
2 parents 0b0d444 + c3b2661 commit 06e8f32

32 files changed

+111
-103
lines changed

docs/introduction/getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ import { createApi } from '@reduxjs/toolkit/query/react'
8686

8787
RTK Query includes these APIs:
8888

89-
- [`createApi()`](../api/rtk-query/createApi.mdx): The core of RTK Query's functionality. It allows you to define a set of endpoints describe how to retrieve data from a series of endpoints, including configuration of how to fetch and transform that data.
90-
- [`fetchBaseQuery()`](../api/rtk-query/fetchBaseQuery.mdx): A small wrapper around [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) that aims to simply requests. Intended as the recommended `baseQuery` to be used in `createApi` for the majority of users.
91-
- [`<ApiProvider />`](../api/rtk-query/ApiProvider.mdx): Can be used as a `Provider` if you **do not already have a Redux store**.
92-
- [`setupListeners()`](../api/rtk-query/setupListeners.mdx): A utility used to enable `refetchOnMount` and `refetchOnReconnect` behaviors.
89+
- [`createApi()`](../rtk-query/api/createApi.mdx): The core of RTK Query's functionality. It allows you to define a set of endpoints describe how to retrieve data from a series of endpoints, including configuration of how to fetch and transform that data.
90+
- [`fetchBaseQuery()`](../rtk-query/api/fetchBaseQuery.mdx): A small wrapper around [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) that aims to simply requests. Intended as the recommended `baseQuery` to be used in `createApi` for the majority of users.
91+
- [`<ApiProvider />`](../rtk-query/api/ApiProvider.mdx): Can be used as a `Provider` if you **do not already have a Redux store**.
92+
- [`setupListeners()`](../rtk-query/api/setupListeners.mdx): A utility used to enable `refetchOnMount` and `refetchOnReconnect` behaviors.
9393

9494
## Help and Discussion
9595

docs/api/rtk-query/ApiProvider.mdx renamed to docs/rtk-query/api/ApiProvider.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ hide_title: true
1212
[examples](docblock://query/react/ApiProvider.tsx?token=ApiProvider)
1313

1414
:::danger
15-
Using this together with an existing Redux store will cause them to conflict with each other. If you are already using Redux, please use follow the instructions as shown in the [Getting Started guide](../../introduction/getting-started).
15+
Using this together with an existing Redux store will cause them to conflict with each other. If you are already using Redux, please follow the instructions as shown in the [Getting Started guide](../../introduction/getting-started).
1616
:::
1717

1818
### Example

docs/api/rtk-query/createApi.mdx renamed to docs/rtk-query/api/createApi.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,15 @@ By default, this function will take the query arguments, sort object keys where
261261
[summary](docblock://query/createApi.ts?token=CreateApiOptions.refetchOnMountOrArgChange)
262262

263263
:::note
264-
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `refetchOnMountOrArgChange` to each individual hook call or when dispatching the [`initiate`](#initiate) action.
264+
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `refetchOnMountOrArgChange` to each individual hook call or when dispatching the [`initiate`](./created-api/endpoints.mdx#initiate) action.
265265
:::
266266

267267
### `refetchOnFocus`
268268

269269
[summary](docblock://query/createApi.ts?token=CreateApiOptions.refetchOnFocus)
270270

271271
:::note
272-
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `refetchOnFocus` to each individual hook call or when dispatching the [`initiate`](#initiate) action.
272+
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `refetchOnFocus` to each individual hook call or when dispatching the [`initiate`](./created-api/endpoints.mdx#initiate) action.
273273

274274
If you specify `track: false` when manually dispatching queries, RTK Query will not be able to automatically refetch for you.
275275
:::
@@ -279,7 +279,7 @@ If you specify `track: false` when manually dispatching queries, RTK Query will
279279
[summary](docblock://query/createApi.ts?token=CreateApiOptions.refetchOnReconnect)
280280

281281
:::note
282-
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `refetchOnReconnect` to each individual hook call or when dispatching the [`initiate`](#initiate) action.
282+
You can set this globally in `createApi`, but you can also override the default value and have more granular control by passing `refetchOnReconnect` to each individual hook call or when dispatching the [`initiate`](./created-api/endpoints.mdx#initiate) action.
283283

284284
If you specify `track: false` when manually dispatching queries, RTK Query will not be able to automatically refetch for you.
285285
:::
@@ -391,7 +391,7 @@ _(optional, only for query endpoints)_
391391

392392
[summary](docblock://query/endpointDefinitions.ts?token=QueryExtraOptions.providesTags)
393393

394-
See also [Providing cache data](../../usage/rtk-query/cached-data.mdx#providing-cache-data).
394+
See also [Providing cache data](../usage/cached-data.mdx#providing-cache-data).
395395

396396
[examples](docblock://query/endpointDefinitions.ts?token=QueryExtraOptions.providesTags)
397397

@@ -401,7 +401,7 @@ _(optional, only for mutation endpoints)_
401401

402402
[summary](docblock://query/endpointDefinitions.ts?token=MutationExtraOptions.invalidatesTags)
403403

404-
See also [Invalidating cache data](../../usage/rtk-query/cached-data.mdx#invalidating-cache-data).
404+
See also [Invalidating cache data](../usage/cached-data.mdx#invalidating-cache-data).
405405

406406
[examples](docblock://query/endpointDefinitions.ts?token=MutationExtraOptions.invalidatesTags)
407407

@@ -419,11 +419,11 @@ Overrides the api-wide definition of `keepUnusedDataFor` for this endpoint only.
419419

420420
_(optional)_
421421

422-
Available to both [queries](../../usage/rtk-query/queries.mdx) and [mutations](../../usage/rtk-query/mutations.mdx).
422+
Available to both [queries](../usage/queries.mdx) and [mutations](../usage/mutations.mdx).
423423

424424
A function that is called when you start each individual query or mutation. The function is called with a lifecycle api object containing properties such as `queryFulfilled`, allowing code to be run when a query is started, when it succeeds, and when it fails (i.e. throughout the lifecycle of an individual query/mutation call).
425425

426-
Can be used in `mutations` for [optimistic updates](../../usage/rtk-query/optimistic-updates.mdx).
426+
Can be used in `mutations` for [optimistic updates](../usage/optimistic-updates.mdx).
427427

428428
#### Lifecycle API properties
429429

@@ -468,11 +468,11 @@ async function onQueryStarted(
468468

469469
_(optional)_
470470

471-
Available to both [queries](../../usage/rtk-query/queries.mdx) and [mutations](../../usage/rtk-query/mutations.mdx).
471+
Available to both [queries](../usage/queries.mdx) and [mutations](../usage/mutations.mdx).
472472

473473
A function that is called when a new cache entry is added, i.e. when a new subscription for the endpoint + query parameters combination is created. The function is called with a lifecycle api object containing properties such as `cacheDataLoaded` & `cacheDataRemoved`, allowing code to be run when a cache entry is added, when cache data is loaded, and when the cache entry is removed (i.e. throughout the lifecycle of a cache entry).
474474

475-
Can be used for [streaming updates](../../usage/rtk-query/streaming-updates.mdx).
475+
Can be used for [streaming updates](../usage/streaming-updates.mdx).
476476

477477
#### Cache Lifecycle API properties
478478

docs/api/rtk-query/created-api/cache-management.mdx renamed to docs/rtk-query/api/created-api/cache-management.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ hide_title: true
77

88
# API Slices: Cache Management Utilities
99

10-
The API slice object includes cache management utilities that are used for implementing [optimistic updates](../../../usage/rtk-query/optimistic-updates.mdx). These are included in a `util` field inside the slice object.
10+
The API slice object includes cache management utilities that are used for implementing [optimistic updates](../../usage/optimistic-updates.mdx). These are included in a `util` field inside the slice object.
1111

1212
### `updateQueryData`
1313

docs/api/rtk-query/created-api/code-splitting.mdx renamed to docs/rtk-query/api/created-api/code-splitting.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ hide_title: true
77

88
# API Slices: Code Splitting and Generation
99

10-
Each API slice allows [additional endpoint definitions to be injected at runtime](../../../usage/rtk-query/code-splitting.mdx) after the initial API slice has been defined. This can be beneficial for apps that may have _many_ endpoints.
10+
Each API slice allows [additional endpoint definitions to be injected at runtime](../../usage/code-splitting.mdx) after the initial API slice has been defined. This can be beneficial for apps that may have _many_ endpoints.
1111

12-
The individual API slice endpoint definitions can also be split across multiple files. This is primarily useful for working with API slices that were [code-generated from an API schema file](../../../usage/rtk-query/code-generation.mdx), allowing you to add additional custom behavior and configuration to a set of automatically-generated endpoint definitions.
12+
The individual API slice endpoint definitions can also be split across multiple files. This is primarily useful for working with API slices that were [code-generated from an API schema file](../../usage/code-generation.mdx), allowing you to add additional custom behavior and configuration to a set of automatically-generated endpoint definitions.
1313

1414
Each API slice object has `injectEndpoints` and `enhanceEndpoints` functions to support these use cases.
1515

docs/api/rtk-query/created-api/endpoints.mdx renamed to docs/rtk-query/api/created-api/endpoints.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ A Redux thunk action creator that you can dispatch to trigger data fetch queries
8585
React Hooks users will most likely never need to use these directly, as the hooks automatically dispatch these actions as needed.
8686

8787
:::note Usage of actions outside of React Hooks
88-
When dispatching an action creator, you're responsible for storing a reference to the promise it returns in the event that you want to update that specific subscription. Also, you have to manually unsubscribe once your component unmounts. To get an idea of what that entails, see the [Svelte Example](../../../usage/rtk-query/examples.mdx#svelte) or the [React Class Components Example](../../../usage/rtk-query/examples.mdx#react-class-components)
88+
When dispatching an action creator, you're responsible for storing a reference to the promise it returns in the event that you want to update that specific subscription. Also, you have to manually unsubscribe once your component unmounts. To get an idea of what that entails, see the [Svelte Example](../../usage/examples.mdx#svelte) or the [React Class Components Example](../../usage/examples.mdx#react-class-components)
8989
:::
9090

9191
## `select`

docs/api/rtk-query/created-api/hooks.mdx renamed to docs/rtk-query/api/created-api/hooks.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ type UseQueryResult<T> = {
279279
```
280280
281281
- **Parameters**
282-
- `arg`: The query argument to be used in constructing the query itself, and as a cache key for the query
282+
- `arg`: The query argument to be used in constructing the query itself, and as a cache key for the query.
283283
You can also pass in `skipToken` here as an alternative way of skipping the query, see [skipToken](#skiptoken)
284284
- `options`: A set of options that control the fetching behavior of the hook
285285
- **Returns**
@@ -396,7 +396,7 @@ type UseQueryStateResult<T> = {
396396
397397
- **Parameters**
398398
399-
- `arg`: The argument passed to the query defined in the endpoint
399+
- `arg`: The argument passed to the query defined in the endpoint.
400400
You can also pass in `skipToken` here as an alternative way of skipping the selection, see [skipToken](#skiptoken)
401401
- `options`: A set of options that control the return value for the hook
402402
@@ -432,7 +432,7 @@ type UseQuerySubscriptionResult = {
432432
433433
- **Parameters**
434434
435-
- `arg`: The argument passed to the query defined in the endpoint
435+
- `arg`: The argument passed to the query defined in the endpoint.
436436
You can also pass in `skipToken` here as an alternative way of skipping the query, see [skipToken](#skiptoken)
437437
- `options`: A set of options that control the fetching behaviour of the hook
438438

docs/api/rtk-query/created-api/overview.mdx renamed to docs/rtk-query/api/created-api/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ The API slice object will have an `endpoints` field inside. This section maps th
7979
8080
## Code Splitting and Generation
8181
82-
Each API slice allows [additional endpoint definitions to be injected at runtime](../../../usage/rtk-query/code-splitting.mdx) after the initial API slice has been defined. This can be beneficial for apps that may have _many_ endpoints.
82+
Each API slice allows [additional endpoint definitions to be injected at runtime](../../usage/code-splitting.mdx) after the initial API slice has been defined. This can be beneficial for apps that may have _many_ endpoints.
8383
84-
The individual API slice endpoint definitions can also be split across multiple files. This is primarily useful for working with API slices that were [code-generated from an API schema file](../../../usage/rtk-query/code-generation.mdx), allowing you to add additional custom behavior and configuration to a set of automatically-generated endpoint definitions.
84+
The individual API slice endpoint definitions can also be split across multiple files. This is primarily useful for working with API slices that were [code-generated from an API schema file](../../usage/code-generation.mdx), allowing you to add additional custom behavior and configuration to a set of automatically-generated endpoint definitions.
8585
8686
Each API slice object has `injectEndpoints` and `enhanceEndpoints` functions to support these use cases.
8787
File renamed without changes.

docs/api/rtk-query/fetchBaseQuery.mdx renamed to docs/rtk-query/api/fetchBaseQuery.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It takes all standard options from fetch's [`RequestInit`](https://developer.moz
1616
- Typically a string like `https://api.your-really-great-app.com/v1/`. If you don't provide a `baseUrl`, it defaults to a relative path from where the request is being made. You should most likely _always_ specify this.
1717
- `prepareHeaders` _(optional)_
1818

19-
- Allows you to inject headers on every request. You can specify headers at the endpoint level, but you'll typically want to set common headers like `authorization` here. As a convience mechanism, the second argument allows you to use `getState` to access your redux store in the event you store information you'll need there such as an auth token.
19+
- Allows you to inject headers on every request. You can specify headers at the endpoint level, but you'll typically want to set common headers like `authorization` here. As a convenience mechanism, the second argument allows you to use `getState` to access your redux store in the event you store information you'll need there such as an auth token.
2020

2121
- ```ts title="prepareHeaders signature" no-transpile
2222
;(headers: Headers, api: { getState: () => unknown }) => Headers

0 commit comments

Comments
 (0)