Skip to content

Commit 4250870

Browse files
committed
Use "build" consistently instead of "builder"
1 parent 0f4f87a commit 4250870

File tree

21 files changed

+85
-88
lines changed

21 files changed

+85
-88
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
7676

7777
export const api = createApi({
7878
baseQuery: fetchBaseQuery({ baseUrl: '/' }),
79-
endpoints: (builder) => ({
80-
getUserByUserId: builder.query({
79+
endpoints: (build) => ({
80+
getUserByUserId: build.query({
8181
query() {
8282
return ''
8383
},
8484
}),
85-
patchUserByUserId: builder.mutation({
85+
patchUserByUserId: build.mutation({
8686
query() {
8787
return ''
8888
},
8989
}),
90-
getUsers: builder.query({
90+
getUsers: build.query({
9191
query() {
9292
return ''
9393
},

docs/rtk-query/api/fetchBaseQuery.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
2626
export const pokemonApi = createApi({
2727
// Set the baseUrl for every endpoint below
2828
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
29-
endpoints: (builder) => ({
30-
getPokemonByName: builder.query({
29+
endpoints: (build) => ({
30+
getPokemonByName: build.query({
3131
// Will make a request like https://pokeapi.co/api/v2/pokemon/bulbasaur
3232
query: (name: string) => `pokemon/${name}`,
3333
}),
34-
updatePokemon: builder.mutation({
34+
updatePokemon: build.mutation({
3535
query: ({ name, patch }) => ({
3636
url: `pokemon/${name}`,
3737
// When performing a mutation, you typically use a method of
@@ -260,8 +260,8 @@ By default, `fetchBaseQuery` assumes that every request you make will be `json`,
260260

261261
```ts no-transpile
262262
// omitted
263-
endpoints: (builder) => ({
264-
updateUser: builder.query({
263+
endpoints: (build) => ({
264+
updateUser: build.query({
265265
query: (user: Record<string, string>) => ({
266266
url: `users`,
267267
method: 'PUT',
@@ -274,8 +274,8 @@ By default, `fetchBaseQuery` assumes that every request you make will be `json`,
274274

275275
```ts no-transpile
276276
// omitted
277-
endpoints: (builder) => ({
278-
updateUser: builder.query({
277+
endpoints: (build) => ({
278+
updateUser: build.query({
279279
query: (user: Record<string, string>) => ({
280280
url: `users`,
281281
method: 'PUT',
@@ -296,8 +296,8 @@ By default, `fetchBaseQuery` assumes that every request you make will be `json`,
296296

297297
```ts no-transpile
298298
// omitted
299-
endpoints: (builder) => ({
300-
updateUser: builder.query({
299+
endpoints: (build) => ({
300+
updateUser: build.query({
301301
query: (user: Record<string, string>) => ({
302302
url: `users`,
303303
// Assuming no `paramsSerializer` is specified, the user object is automatically converted
@@ -328,8 +328,8 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
328328
329329
export const customApi = createApi({
330330
baseQuery: fetchBaseQuery({ baseUrl: '/api/' }),
331-
endpoints: (builder) => ({
332-
getUsers: builder.query({
331+
endpoints: (build) => ({
332+
getUsers: build.query({
333333
query: () => ({
334334
url: `users`,
335335
// This is the same as passing 'text'
@@ -365,8 +365,8 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
365365
export const customApi = createApi({
366366
// Set the baseUrl for every endpoint below
367367
baseQuery: fetchBaseQuery({ baseUrl: '/api/' }),
368-
endpoints: (builder) => ({
369-
getUsers: builder.query({
368+
endpoints: (build) => ({
369+
getUsers: build.query({
370370
query: () => ({
371371
url: `users`,
372372
// Example: we have a backend API always returns a 200,
@@ -389,8 +389,8 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
389389
export const api = createApi({
390390
// Set a default timeout of 10 seconds
391391
baseQuery: fetchBaseQuery({ baseUrl: '/api/', timeout: 10000 }),
392-
endpoints: (builder) => ({
393-
getUsers: builder.query({
392+
endpoints: (build) => ({
393+
getUsers: build.query({
394394
query: () => ({
395395
url: `users`,
396396
// Example: we know the users endpoint is _really fast_ because it's always cached.

docs/rtk-query/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ import type { Pokemon } from './types'
121121
export const pokemonApi = createApi({
122122
reducerPath: 'pokemonApi',
123123
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
124-
endpoints: (builder) => ({
125-
getPokemonByName: builder.query<Pokemon, string>({
124+
endpoints: (build) => ({
125+
getPokemonByName: build.query<Pokemon, string>({
126126
query: (name) => `pokemon/${name}`,
127127
}),
128128
}),

docs/rtk-query/usage-with-typescript.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import type { Pokemon } from './types'
5151
export const pokemonApi = createApi({
5252
reducerPath: 'pokemonApi',
5353
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
54-
endpoints: (builder) => ({
55-
getPokemonByName: builder.query<Pokemon, string>({
54+
endpoints: (build) => ({
55+
getPokemonByName: build.query<Pokemon, string>({
5656
query: (name) => `pokemon/${name}`,
5757
}),
5858
}),
@@ -78,8 +78,8 @@ import type { Pokemon } from './types'
7878
export const pokemonApi = createApi({
7979
reducerPath: 'pokemonApi',
8080
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
81-
endpoints: (builder) => ({
82-
getPokemonByName: builder.query<Pokemon, string>({
81+
endpoints: (build) => ({
82+
getPokemonByName: build.query<Pokemon, string>({
8383
query: (name) => `pokemon/${name}`,
8484
}),
8585
}),
@@ -178,8 +178,8 @@ const simpleBaseQuery: BaseQueryFn<
178178

179179
const api = createApi({
180180
baseQuery: simpleBaseQuery,
181-
endpoints: (builder) => ({
182-
getSupport: builder.query({
181+
endpoints: (build) => ({
182+
getSupport: build.query({
183183
query: () => 'support me',
184184
extraOptions: {
185185
shout: true,

docs/rtk-query/usage/cache-behavior.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ export const api = createApi({
100100
// global configuration for the api
101101
keepUnusedDataFor: 30,
102102
// highlight-end
103-
endpoints: (builder) => ({
104-
getPosts: builder.query<Post[], number>({
103+
endpoints: (build) => ({
104+
getPosts: build.query<Post[], number>({
105105
query: () => `posts`,
106106
// highlight-start
107107
// configuration for an individual endpoint, overriding the api setting
@@ -189,8 +189,8 @@ export const api = createApi({
189189
// global configuration for the api
190190
refetchOnMountOrArgChange: 30,
191191
// highlight-end
192-
endpoints: (builder) => ({
193-
getPosts: builder.query<Post[], number>({
192+
endpoints: (build) => ({
193+
getPosts: build.query<Post[], number>({
194194
query: () => `posts`,
195195
}),
196196
}),
@@ -241,8 +241,8 @@ export const api = createApi({
241241
// global configuration for the api
242242
refetchOnFocus: true,
243243
// highlight-end
244-
endpoints: (builder) => ({
245-
getPosts: builder.query<Post[], number>({
244+
endpoints: (build) => ({
245+
getPosts: build.query<Post[], number>({
246246
query: () => `posts`,
247247
}),
248248
}),
@@ -266,8 +266,8 @@ export const api = createApi({
266266
// global configuration for the api
267267
refetchOnFocus: true,
268268
// highlight-end
269-
endpoints: (builder) => ({
270-
getPosts: builder.query<Post[], number>({
269+
endpoints: (build) => ({
270+
getPosts: build.query<Post[], number>({
271271
query: () => `posts`,
272272
}),
273273
}),
@@ -320,8 +320,8 @@ export const api = createApi({
320320
// global configuration for the api
321321
refetchOnReconnect: true,
322322
// highlight-end
323-
endpoints: (builder) => ({
324-
getPosts: builder.query<Post[], number>({
323+
endpoints: (build) => ({
324+
getPosts: build.query<Post[], number>({
325325
query: () => `posts`,
326326
}),
327327
}),
@@ -345,8 +345,8 @@ export const api = createApi({
345345
// global configuration for the api
346346
refetchOnReconnect: true,
347347
// highlight-end
348-
endpoints: (builder) => ({
349-
getPosts: builder.query<Post[], number>({
348+
endpoints: (build) => ({
349+
getPosts: build.query<Post[], number>({
350350
query: () => `posts`,
351351
}),
352352
}),

docs/rtk-query/usage/customizing-queries.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ export const api = createApi({
446446
baseUrl: 'https://graphqlzero.almansi.me/api',
447447
}),
448448
// highlight-end
449-
endpoints: (builder) => ({
450-
getPosts: builder.query({
449+
endpoints: (build) => ({
450+
getPosts: build.query({
451451
query: () => ({
452452
body: gql`
453453
query {
@@ -462,7 +462,7 @@ export const api = createApi({
462462
}),
463463
transformResponse: (response) => response.posts.data,
464464
}),
465-
getPost: builder.query({
465+
getPost: build.query({
466466
query: (id) => ({
467467
body: gql`
468468
query {
@@ -823,8 +823,8 @@ const dynamicBaseQuery: BaseQueryFn<
823823
824824
export const api = createApi({
825825
baseQuery: dynamicBaseQuery,
826-
endpoints: (builder) => ({
827-
getPosts: builder.query<Post[], void>({
826+
endpoints: (build) => ({
827+
getPosts: build.query<Post[], void>({
828828
query: () => 'posts',
829829
}),
830830
}),
@@ -862,8 +862,8 @@ export const api = createApi({
862862
baseQuery: graphqlBaseQuery({
863863
baseUrl: '/graphql',
864864
}),
865-
endpoints: (builder) => ({
866-
getPosts: builder.query<Post[], void>({
865+
endpoints: (build) => ({
866+
getPosts: build.query<Post[], void>({
867867
query: () => ({
868868
body: gql`
869869
query {
@@ -959,8 +959,8 @@ import { supabase } from './supabaseApi'
959959
export const supabaseApi = createApi({
960960
reducerPath: 'supabaseApi',
961961
baseQuery: fakeBaseQuery(),
962-
endpoints: (builder) => ({
963-
getBlogs: builder.query({
962+
endpoints: (build) => ({
963+
getBlogs: build.query({
964964
queryFn: async () => {
965965
// Supabase conveniently already has `data` and `error` fields
966966
const { data, error } = await supabase.from('blogs').select()

docs/rtk-query/usage/migrating-to-rtk-query.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ interface Pokemon {}
375375

376376
export const api = createApi({
377377
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
378-
endpoints: (builder) => ({
379-
getPokemonByName: builder.query<Pokemon, string>({
378+
endpoints: (build) => ({
379+
getPokemonByName: build.query<Pokemon, string>({
380380
query: (name) => `pokemon/${name}`,
381381
}),
382382
}),

docs/rtk-query/usage/pagination.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ interface ListResponse<T> {
3232

3333
export const api = createApi({
3434
baseQuery: fetchBaseQuery({ baseUrl: '/' }),
35-
endpoints: (builder) => ({
36-
listPosts: builder.query<ListResponse<Post>, number | void>({
35+
endpoints: (build) => ({
36+
listPosts: build.query<ListResponse<Post>, number | void>({
3737
query: (page = 1) => `posts?page=${page}`,
3838
}),
3939
}),

docs/rtk-query/usage/queries.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ See [`useQuery`](../api/created-api/hooks.mdx#usequery) for the hook signature a
2626

2727
## Defining Query Endpoints
2828

29-
Query endpoints are defined by returning an object inside the `endpoints` section of `createApi`, and defining the fields using the `builder.query()` method.
29+
Query endpoints are defined by returning an object inside the `endpoints` section of `createApi`, and defining the fields using the `build.query()` method.
3030

3131
Query endpoints should define either a `query` callback that constructs the URL (including any URL query params), or [a `queryFn` callback](./customizing-queries.mdx#customizing-queries-with-queryfn) that may do arbitrary async logic and return a result.
3232

@@ -105,7 +105,7 @@ const api = createApi({
105105

106106
If you're using React Hooks, RTK Query does a few additional things for you. The primary benefit is that you get a render-optimized hook that allows you to have 'background fetching' as well as [derived booleans](#frequently-used-query-hook-return-values) for convenience.
107107

108-
Hooks are automatically generated based on the name of the `endpoint` in the service definition. An endpoint field with `getPost: builder.query()` will generate a hook named `useGetPostQuery`, as well as a generically-named hook attached to the endpoint, like `api.endpoints.getPost.useQuery`.
108+
Hooks are automatically generated based on the name of the `endpoint` in the service definition. An endpoint field with `getPost: build.query()` will generate a hook named `useGetPostQuery`, as well as a generically-named hook attached to the endpoint, like `api.endpoints.getPost.useQuery`.
109109

110110
### Hook types
111111

examples/query/react/advanced/src/services/pokemon.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export const pokemonApi = createApi({
44
reducerPath: 'pokemonApi',
55
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
66
tagTypes: [],
7-
endpoints: (builder) => ({
8-
getPokemonByName: builder.query({
7+
endpoints: (build) => ({
8+
getPokemonByName: build.query({
99
query: (name: string) => `pokemon/${name}`,
1010
}),
1111
}),

0 commit comments

Comments
 (0)