[{"data":1,"prerenderedAt":1396},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-react-query\u002Fguides\u002Fcalling-operations":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":1395,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-react-query\u002Fguides\u002Fcalling-operations.md",{},"Call operations",{"type":8,"value":9,"toc":1382},"minimark",[10,55,85,90,107,195,220,337,341,350,479,483,492,621,629,633,657,661,671,750,761,765,779,986,1000,1004,1013,1113,1117,1126,1215,1232,1379],[11,12,13,17,18,21,22,25,26,29,30,29,33,25,36,39,40,43,44,29,47,50,51,54],"p",{},[14,15,16],"code",{},"@kubb\u002Fplugin-react-query"," can generate a typed TanStack Query hook for each operation. ",[14,19,20],{},"GET"," operations get query hooks such as ",[14,23,24],{},"useGetPetById",", and ",[14,27,28],{},"POST",", ",[14,31,32],{},"PUT",[14,34,35],{},"PATCH",[14,37,38],{},"DELETE"," operations get mutation hooks such as ",[14,41,42],{},"useDeletePet",". Each hook calls the client function from ",[14,45,46],{},"@kubb\u002Fplugin-fetch",[14,48,49],{},"@kubb\u002Fplugin-axios",", or ",[14,52,53],{},"@kubb\u002Fplugin-client",".",[56,57,59,60,29,63,29,66,29,69,72,73,80,81,84],"blockquote",{"as":58},"important","By default the plugin emits only the factory helpers (",[14,61,62],{},"queryOptions",[14,64,65],{},"mutationOptions",[14,67,68],{},"queryKey",[14,70,71],{},"mutationKey","). Set ",[74,75,77],"a",{"href":76},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-react-query\u002Foptions#hooks",[14,78,79],{},"hooks: true"," in the plugin options to also generate the ",[14,82,83],{},"use*"," hooks shown below.",[86,87,89],"h2",{"id":88},"queries","Queries",[11,91,92,93,29,96,29,99,102,103,106],{},"A query hook takes the operation's grouped request config (",[14,94,95],{},"path",[14,97,98],{},"query",[14,100,101],{},"headers",", whichever the operation declares) as its first argument and returns a TanStack ",[14,104,105],{},"UseQueryResult",":",[108,109,113],"pre",{"language":110,"code":111,"class":112},"typescript","import { useGetPetById } from '.\u002Fgen\u002Fhooks\u002FuseGetPetById'\n\nconst { data, error, isLoading } = useGetPetById({ path: { petId: 1n } })","highlights",[14,114,116,143,144,143,146],{"class":115},"language-typescript",[117,118,121,125,129,133,136,139],"span",{"class":119,"style":120},"line","display: inline",[117,122,124],{"style":123},"color:#d73a49;--hls-dark:#f97583","import ",[117,126,128],{"style":127},"color:#005cc5;--hls-dark:#79b8ff","{ ",[117,130,132],{"style":131},"color:#24292e;--hls-dark:#e1e4e8","useGetPetById ",[117,134,135],{"style":127},"} ",[117,137,138],{"style":123},"from ",[117,140,142],{"style":141},"color:#032f62;--hls-dark:#9ecbff","'.\u002Fgen\u002Fhooks\u002FuseGetPetById'","\n",[117,145],{"class":119,"style":120},[117,147,148,151,153,156,158,161,163,166,168,171,174,177,179,182,184,187,189,192],{"class":119,"style":120},[117,149,150],{"style":123},"const ",[117,152,128],{"style":127},[117,154,155],{"style":131},"data",[117,157,29],{"style":123},[117,159,160],{"style":131},"error",[117,162,29],{"style":123},[117,164,165],{"style":131},"isLoading ",[117,167,135],{"style":127},[117,169,170],{"style":123},"= ",[117,172,24],{"style":173},"color:#6f42c1;--hls-dark:#b392f0",[117,175,176],{"style":127},"({ ",[117,178,95],{"style":127},[117,180,181],{"style":123},": ",[117,183,128],{"style":127},[117,185,186],{"style":127},"petId",[117,188,181],{"style":123},[117,190,191],{"style":127},"1n ",[117,193,194],{"style":127},"} })",[11,196,197,198,200,201,204,205,208,209,212,213,216,217,106],{},"The second argument has two optional groups. ",[14,199,98],{}," takes any TanStack Query option, and ",[14,202,203],{},"query.client"," sets the ",[14,206,207],{},"QueryClient"," to use. The top-level ",[14,210,211],{},"client"," takes request config for this call, such as ",[14,214,215],{},"baseURL"," or ",[14,218,219],{},"signal",[108,221,223],{"language":110,"code":222,"class":112},"import { useGetPetById } from '.\u002Fgen\u002Fhooks\u002FuseGetPetById'\n\nuseGetPetById(\n  { path: { petId: 1n } },\n  {\n    query: { staleTime: 60_000 },\n    client: { baseURL: 'https:\u002F\u002Fapi.example.com\u002Fv1' },\n  },\n)",[14,224,225,143,239,143,241,143,248,143,271,143,279,143,303,143,324,143,332],{"class":115},[117,226,227,229,231,233,235,237],{"class":119,"style":120},[117,228,124],{"style":123},[117,230,128],{"style":127},[117,232,132],{"style":131},[117,234,135],{"style":127},[117,236,138],{"style":123},[117,238,142],{"style":141},[117,240],{"class":119,"style":120},[117,242,243,245],{"class":119,"style":120},[117,244,24],{"style":173},[117,246,247],{"style":127},"(",[117,249,250,253,255,257,259,261,263,265,268],{"class":119,"style":120},[117,251,252],{"style":127},"  { ",[117,254,95],{"style":127},[117,256,181],{"style":123},[117,258,128],{"style":127},[117,260,186],{"style":127},[117,262,181],{"style":123},[117,264,191],{"style":127},[117,266,267],{"style":127},"} }",[117,269,270],{"style":123},",",[117,272,273,276],{"class":119,"style":120},[117,274,275],{"style":123},"  ",[117,277,278],{"style":127},"{",[117,280,281,284,286,288,290,293,295,298,301],{"class":119,"style":120},[117,282,283],{"style":127},"    ",[117,285,98],{"style":127},[117,287,181],{"style":123},[117,289,128],{"style":127},[117,291,292],{"style":127},"staleTime",[117,294,181],{"style":123},[117,296,297],{"style":127},"60_000 ",[117,299,300],{"style":127},"}",[117,302,270],{"style":123},[117,304,305,307,309,311,313,315,317,320,322],{"class":119,"style":120},[117,306,283],{"style":123},[117,308,211],{"style":127},[117,310,181],{"style":123},[117,312,128],{"style":127},[117,314,215],{"style":127},[117,316,181],{"style":123},[117,318,319],{"style":141},"'https:\u002F\u002Fapi.example.com\u002Fv1' ",[117,321,300],{"style":127},[117,323,270],{"style":123},[117,325,326,328,330],{"class":119,"style":120},[117,327,275],{"style":123},[117,329,300],{"style":127},[117,331,270],{"style":123},[117,333,334],{"class":119,"style":120},[117,335,336],{"style":127},")",[86,338,340],{"id":339},"factories","Factories",[11,342,343,344,346,347,349],{},"Each query operation also exports a ",[14,345,62],{}," factory and a ",[14,348,68],{}," helper. Use them to prefetch or invalidate a query outside a hook. The key includes the operation URL and path parameters, followed by query or body values when present:",[108,351,353],{"language":110,"code":352,"class":112},"import { useQueryClient } from '@tanstack\u002Freact-query'\nimport { getPetByIdQueryKey, getPetByIdQueryOptions } from '.\u002Fgen\u002Fhooks\u002FuseGetPetById'\n\nconst queryClient = useQueryClient()\n\nawait queryClient.prefetchQuery(getPetByIdQueryOptions({ path: { petId: 1n } }))\nqueryClient.invalidateQueries({ queryKey: getPetByIdQueryKey({ path: { petId: 1n } }) })",[14,354,355,143,371,143,391,143,393,143,408,143,410,143,445],{"class":115},[117,356,357,359,361,364,366,368],{"class":119,"style":120},[117,358,124],{"style":123},[117,360,128],{"style":127},[117,362,363],{"style":131},"useQueryClient ",[117,365,135],{"style":127},[117,367,138],{"style":123},[117,369,370],{"style":141},"'@tanstack\u002Freact-query'",[117,372,373,375,377,380,382,385,387,389],{"class":119,"style":120},[117,374,124],{"style":123},[117,376,128],{"style":127},[117,378,379],{"style":131},"getPetByIdQueryKey",[117,381,29],{"style":123},[117,383,384],{"style":131},"getPetByIdQueryOptions ",[117,386,135],{"style":127},[117,388,138],{"style":123},[117,390,142],{"style":141},[117,392],{"class":119,"style":120},[117,394,395,397,400,402,405],{"class":119,"style":120},[117,396,150],{"style":123},[117,398,399],{"style":131},"queryClient ",[117,401,170],{"style":123},[117,403,404],{"style":173},"useQueryClient",[117,406,407],{"style":127},"()",[117,409],{"class":119,"style":120},[117,411,412,415,418,420,423,425,428,430,432,434,436,438,440,442],{"class":119,"style":120},[117,413,414],{"style":123},"await ",[117,416,417],{"style":131},"queryClient",[117,419,54],{"style":123},[117,421,422],{"style":173},"prefetchQuery",[117,424,247],{"style":127},[117,426,427],{"style":173},"getPetByIdQueryOptions",[117,429,176],{"style":127},[117,431,95],{"style":127},[117,433,181],{"style":123},[117,435,128],{"style":127},[117,437,186],{"style":127},[117,439,181],{"style":123},[117,441,191],{"style":127},[117,443,444],{"style":127},"} }))",[117,446,447,449,451,454,456,458,460,462,464,466,468,470,472,474,476],{"class":119,"style":120},[117,448,417],{"style":131},[117,450,54],{"style":123},[117,452,453],{"style":173},"invalidateQueries",[117,455,176],{"style":127},[117,457,68],{"style":127},[117,459,181],{"style":123},[117,461,379],{"style":173},[117,463,176],{"style":127},[117,465,95],{"style":127},[117,467,181],{"style":123},[117,469,128],{"style":127},[117,471,186],{"style":127},[117,473,181],{"style":123},[117,475,191],{"style":127},[117,477,478],{"style":127},"} }) })",[86,480,482],{"id":481},"mutations","Mutations",[11,484,485,486,216,489,106],{},"A mutation hook takes only an options object. The grouped request config is the mutation variable, so you pass it to ",[14,487,488],{},"mutate",[14,490,491],{},"mutateAsync",[108,493,495],{"language":110,"code":494,"class":112},"import { useQueryClient } from '@tanstack\u002Freact-query'\nimport { useDeletePet } from '.\u002Fgen\u002Fhooks\u002FuseDeletePet'\n\nconst queryClient = useQueryClient()\n\nconst { mutate } = useDeletePet({\n  mutation: { onSuccess: () => queryClient.invalidateQueries() },\n})\n\nmutate({ path: { petId: 1n } })",[14,496,497,143,511,143,527,143,529,143,541,143,543,143,561,143,594,143,599,143,601],{"class":115},[117,498,499,501,503,505,507,509],{"class":119,"style":120},[117,500,124],{"style":123},[117,502,128],{"style":127},[117,504,363],{"style":131},[117,506,135],{"style":127},[117,508,138],{"style":123},[117,510,370],{"style":141},[117,512,513,515,517,520,522,524],{"class":119,"style":120},[117,514,124],{"style":123},[117,516,128],{"style":127},[117,518,519],{"style":131},"useDeletePet ",[117,521,135],{"style":127},[117,523,138],{"style":123},[117,525,526],{"style":141},"'.\u002Fgen\u002Fhooks\u002FuseDeletePet'",[117,528],{"class":119,"style":120},[117,530,531,533,535,537,539],{"class":119,"style":120},[117,532,150],{"style":123},[117,534,399],{"style":131},[117,536,170],{"style":123},[117,538,404],{"style":173},[117,540,407],{"style":127},[117,542],{"class":119,"style":120},[117,544,545,547,549,552,554,556,558],{"class":119,"style":120},[117,546,150],{"style":123},[117,548,128],{"style":127},[117,550,551],{"style":131},"mutate ",[117,553,135],{"style":127},[117,555,170],{"style":123},[117,557,42],{"style":173},[117,559,560],{"style":127},"({",[117,562,563,565,568,570,572,575,577,580,583,585,587,589,592],{"class":119,"style":120},[117,564,275],{"style":127},[117,566,567],{"style":127},"mutation",[117,569,181],{"style":123},[117,571,128],{"style":127},[117,573,574],{"style":127},"onSuccess",[117,576,181],{"style":123},[117,578,579],{"style":127},"() ",[117,581,582],{"style":123},"=> ",[117,584,417],{"style":131},[117,586,54],{"style":123},[117,588,453],{"style":173},[117,590,591],{"style":127},"() }",[117,593,270],{"style":123},[117,595,596],{"class":119,"style":120},[117,597,598],{"style":127},"})",[117,600],{"class":119,"style":120},[117,602,603,605,607,609,611,613,615,617,619],{"class":119,"style":120},[117,604,488],{"style":173},[117,606,176],{"style":127},[117,608,95],{"style":127},[117,610,181],{"style":123},[117,612,128],{"style":127},[117,614,186],{"style":127},[117,616,181],{"style":123},[117,618,191],{"style":127},[117,620,194],{"style":127},[11,622,623,624,346,626,628],{},"Each mutation also exports a ",[14,625,65],{},[14,627,71],{}," helper.",[86,630,632],{"id":631},"errors-and-transport","Errors and transport",[11,634,635,636,639,640,642,643,216,647,651,652,656],{},"Each generated hook calls the client function with ",[14,637,638],{},"throwOnError: true",". A failed request sets TanStack Query's ",[14,641,160],{},", typed from the error responses in the spec. Set the base URL, authentication, interceptors, serialization, and validation on the client plugin. See the ",[74,644,646],{"href":645},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-fetch","plugin-fetch",[74,648,650],{"href":649},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-axios","plugin-axios"," guide. With ",[74,653,655],{"href":654},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-client","plugin-client",", set these in your own client module.",[86,658,660],{"id":659},"customize-cache-keys","Customize cache keys",[11,662,663,664,666,667,670],{},"Set ",[14,665,68],{}," on the plugin to change generated keys. String entries are emitted as source code, so use ",[14,668,669],{},"JSON.stringify"," for a string literal.",[108,672,675],{"language":110,"filename":673,"code":674,"class":112},"kubb.config.ts","import { pluginReactQuery } from '@kubb\u002Fplugin-react-query'\n\npluginReactQuery({\n  queryKey: ({ node }) => [JSON.stringify(node.operationId)],\n})",[14,676,677,143,693,143,695,143,702,143,746],{"class":115},[117,678,679,681,683,686,688,690],{"class":119,"style":120},[117,680,124],{"style":123},[117,682,128],{"style":127},[117,684,685],{"style":131},"pluginReactQuery ",[117,687,135],{"style":127},[117,689,138],{"style":123},[117,691,692],{"style":141},"'@kubb\u002Fplugin-react-query'",[117,694],{"class":119,"style":120},[117,696,697,700],{"class":119,"style":120},[117,698,699],{"style":173},"pluginReactQuery",[117,701,560],{"style":127},[117,703,704,706,708,710,712,715,718,720,723,726,728,731,733,736,738,741,744],{"class":119,"style":120},[117,705,275],{"style":127},[117,707,68],{"style":127},[117,709,181],{"style":123},[117,711,176],{"style":127},[117,713,714],{"style":131},"node ",[117,716,717],{"style":127},"}) ",[117,719,582],{"style":123},[117,721,722],{"style":127},"[",[117,724,725],{"style":127},"JSON",[117,727,54],{"style":123},[117,729,730],{"style":173},"stringify",[117,732,247],{"style":127},[117,734,735],{"style":131},"node",[117,737,54],{"style":123},[117,739,740],{"style":127},"operationId",[117,742,743],{"style":127},")]",[117,745,270],{"style":123},[117,747,748],{"class":119,"style":120},[117,749,598],{"style":127},[56,751,753,754,756,757,760],{"as":752},"warning","This ",[14,755,68],{}," gives every call the same key, such as ",[14,758,759],{},"['getUserByName']",". If path or query values select different data, add them to the key.",[86,762,764],{"id":763},"load-more-pages","Load more pages",[11,766,767,768,771,772,774,775,778],{},"Configure ",[14,769,770],{},"infinite"," with a query parameter declared by the operation, its initial value, and the response path for the next cursor. Infinite output needs ",[14,773,79],{},", and only operations that declare the ",[14,776,777],{},"queryParam"," receive it.",[780,781,782,886],"code-group",{},[108,783,785],{"language":110,"filename":673,"code":784,"class":112},"import { pluginReactQuery } from '@kubb\u002Fplugin-react-query'\n\npluginReactQuery({\n  hooks: true,\n  infinite: {\n    queryParam: 'page',\n    initialPageParam: 0,\n    nextParam: 'pagination.next.cursor',\n  },\n})",[14,786,787,143,801,143,803,143,809,143,823,143,833,143,846,143,860,143,874,143,882],{"class":115},[117,788,789,791,793,795,797,799],{"class":119,"style":120},[117,790,124],{"style":123},[117,792,128],{"style":127},[117,794,685],{"style":131},[117,796,135],{"style":127},[117,798,138],{"style":123},[117,800,692],{"style":141},[117,802],{"class":119,"style":120},[117,804,805,807],{"class":119,"style":120},[117,806,699],{"style":173},[117,808,560],{"style":127},[117,810,811,813,816,818,821],{"class":119,"style":120},[117,812,275],{"style":127},[117,814,815],{"style":127},"hooks",[117,817,181],{"style":123},[117,819,820],{"style":127},"true",[117,822,270],{"style":123},[117,824,825,827,829,831],{"class":119,"style":120},[117,826,275],{"style":123},[117,828,770],{"style":127},[117,830,181],{"style":123},[117,832,278],{"style":127},[117,834,835,837,839,841,844],{"class":119,"style":120},[117,836,283],{"style":127},[117,838,777],{"style":127},[117,840,181],{"style":123},[117,842,843],{"style":141},"'page'",[117,845,270],{"style":123},[117,847,848,850,853,855,858],{"class":119,"style":120},[117,849,283],{"style":123},[117,851,852],{"style":127},"initialPageParam",[117,854,181],{"style":123},[117,856,857],{"style":127},"0",[117,859,270],{"style":123},[117,861,862,864,867,869,872],{"class":119,"style":120},[117,863,283],{"style":123},[117,865,866],{"style":127},"nextParam",[117,868,181],{"style":123},[117,870,871],{"style":141},"'pagination.next.cursor'",[117,873,270],{"style":123},[117,875,876,878,880],{"class":119,"style":120},[117,877,275],{"style":123},[117,879,300],{"style":127},[117,881,270],{"style":123},[117,883,884],{"class":119,"style":120},[117,885,598],{"style":127},[108,887,890],{"language":110,"filename":888,"code":889,"class":112},"usage.ts","import { useInfiniteQuery } from '@tanstack\u002Freact-query'\nimport { findPetsByTagsInfiniteQueryOptions } from '.\u002Fgen\u002Fhooks\u002FuseFindPetsByTagsInfinite'\n\nconst { data, fetchNextPage, hasNextPage } = useInfiniteQuery(\n  findPetsByTagsInfiniteQueryOptions({ query: { tags: ['dog'] } }),\n)",[14,891,892,143,907,143,923,143,925,143,952,143,982],{"class":115},[117,893,894,896,898,901,903,905],{"class":119,"style":120},[117,895,124],{"style":123},[117,897,128],{"style":127},[117,899,900],{"style":131},"useInfiniteQuery ",[117,902,135],{"style":127},[117,904,138],{"style":123},[117,906,370],{"style":141},[117,908,909,911,913,916,918,920],{"class":119,"style":120},[117,910,124],{"style":123},[117,912,128],{"style":127},[117,914,915],{"style":131},"findPetsByTagsInfiniteQueryOptions ",[117,917,135],{"style":127},[117,919,138],{"style":123},[117,921,922],{"style":141},"'.\u002Fgen\u002Fhooks\u002FuseFindPetsByTagsInfinite'",[117,924],{"class":119,"style":120},[117,926,927,929,931,933,935,938,940,943,945,947,950],{"class":119,"style":120},[117,928,150],{"style":123},[117,930,128],{"style":127},[117,932,155],{"style":131},[117,934,29],{"style":123},[117,936,937],{"style":131},"fetchNextPage",[117,939,29],{"style":123},[117,941,942],{"style":131},"hasNextPage ",[117,944,135],{"style":127},[117,946,170],{"style":123},[117,948,949],{"style":173},"useInfiniteQuery",[117,951,247],{"style":127},[117,953,954,956,959,961,963,965,967,970,972,974,977,980],{"class":119,"style":120},[117,955,275],{"style":127},[117,957,958],{"style":173},"findPetsByTagsInfiniteQueryOptions",[117,960,176],{"style":127},[117,962,98],{"style":127},[117,964,181],{"style":123},[117,966,128],{"style":127},[117,968,969],{"style":127},"tags",[117,971,181],{"style":123},[117,973,722],{"style":127},[117,975,976],{"style":141},"'dog'",[117,978,979],{"style":127},"] } })",[117,981,270],{"style":123},[117,983,984],{"class":119,"style":120},[117,985,336],{"style":127},[11,987,988,990,991,29,994,216,996,999],{},[14,989,866],{}," takes dot notation or an array of keys. Change it to match your API's response. Without ",[14,992,993],{},"getNextPageParam",[14,995,866],{},[14,997,998],{},"cursorParam",", the generated options increment the page number until a page returns an empty array.",[86,1001,1003],{"id":1002},"use-suspense","Use suspense",[11,1005,663,1006,1009,1010,1012],{},[14,1007,1008],{},"suspense: {}"," and ",[14,1011,79],{}," to generate suspense hooks alongside regular hooks. Suspense requires TanStack Query v5 or higher.",[780,1014,1015,1058],{},[108,1016,1018],{"language":110,"filename":673,"code":1017,"class":112},"import { pluginReactQuery } from '@kubb\u002Fplugin-react-query'\n\npluginReactQuery({ hooks: true, suspense: {} })",[14,1019,1020,143,1034,143,1036],{"class":115},[117,1021,1022,1024,1026,1028,1030,1032],{"class":119,"style":120},[117,1023,124],{"style":123},[117,1025,128],{"style":127},[117,1027,685],{"style":131},[117,1029,135],{"style":127},[117,1031,138],{"style":123},[117,1033,692],{"style":141},[117,1035],{"class":119,"style":120},[117,1037,1038,1040,1042,1044,1046,1048,1050,1053,1055],{"class":119,"style":120},[117,1039,699],{"style":173},[117,1041,176],{"style":127},[117,1043,815],{"style":127},[117,1045,181],{"style":123},[117,1047,820],{"style":127},[117,1049,29],{"style":123},[117,1051,1052],{"style":127},"suspense",[117,1054,181],{"style":123},[117,1056,1057],{"style":127},"{} })",[108,1059,1061],{"language":110,"filename":888,"code":1060,"class":112},"import { useGetPetByIdSuspense } from '.\u002Fgen\u002Fhooks\u002FuseGetPetByIdSuspense'\n\nconst { data } = useGetPetByIdSuspense({ path: { petId: 1n } })",[14,1062,1063,143,1079,143,1081],{"class":115},[117,1064,1065,1067,1069,1072,1074,1076],{"class":119,"style":120},[117,1066,124],{"style":123},[117,1068,128],{"style":127},[117,1070,1071],{"style":131},"useGetPetByIdSuspense ",[117,1073,135],{"style":127},[117,1075,138],{"style":123},[117,1077,1078],{"style":141},"'.\u002Fgen\u002Fhooks\u002FuseGetPetByIdSuspense'",[117,1080],{"class":119,"style":120},[117,1082,1083,1085,1087,1090,1092,1094,1097,1099,1101,1103,1105,1107,1109,1111],{"class":119,"style":120},[117,1084,150],{"style":123},[117,1086,128],{"style":127},[117,1088,1089],{"style":131},"data ",[117,1091,135],{"style":127},[117,1093,170],{"style":123},[117,1095,1096],{"style":173},"useGetPetByIdSuspense",[117,1098,176],{"style":127},[117,1100,95],{"style":127},[117,1102,181],{"style":123},[117,1104,128],{"style":127},[117,1106,186],{"style":127},[117,1108,181],{"style":123},[117,1110,191],{"style":127},[117,1112,194],{"style":127},[86,1114,1116],{"id":1115},"share-hook-options","Share hook options",[11,1118,663,1119,1125],{},[74,1120,1122],{"href":1121},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-react-query\u002Foptions#customoptions",[14,1123,1124],{},"customOptions"," to call one options function from every generated hook.",[108,1127,1129],{"language":110,"filename":673,"code":1128,"class":112},"import { pluginReactQuery } from '@kubb\u002Fplugin-react-query'\n\npluginReactQuery({\n  hooks: true,\n  customOptions: {\n    importPath: '.\u002FuseCustomHookOptions',\n    name: 'useCustomHookOptions',\n  },\n})",[14,1130,1131,143,1145,143,1147,143,1153,143,1165,143,1175,143,1189,143,1203,143,1211],{"class":115},[117,1132,1133,1135,1137,1139,1141,1143],{"class":119,"style":120},[117,1134,124],{"style":123},[117,1136,128],{"style":127},[117,1138,685],{"style":131},[117,1140,135],{"style":127},[117,1142,138],{"style":123},[117,1144,692],{"style":141},[117,1146],{"class":119,"style":120},[117,1148,1149,1151],{"class":119,"style":120},[117,1150,699],{"style":173},[117,1152,560],{"style":127},[117,1154,1155,1157,1159,1161,1163],{"class":119,"style":120},[117,1156,275],{"style":127},[117,1158,815],{"style":127},[117,1160,181],{"style":123},[117,1162,820],{"style":127},[117,1164,270],{"style":123},[117,1166,1167,1169,1171,1173],{"class":119,"style":120},[117,1168,275],{"style":123},[117,1170,1124],{"style":127},[117,1172,181],{"style":123},[117,1174,278],{"style":127},[117,1176,1177,1179,1182,1184,1187],{"class":119,"style":120},[117,1178,283],{"style":127},[117,1180,1181],{"style":127},"importPath",[117,1183,181],{"style":123},[117,1185,1186],{"style":141},"'.\u002FuseCustomHookOptions'",[117,1188,270],{"style":123},[117,1190,1191,1193,1196,1198,1201],{"class":119,"style":120},[117,1192,283],{"style":123},[117,1194,1195],{"style":127},"name",[117,1197,181],{"style":123},[117,1199,1200],{"style":141},"'useCustomHookOptions'",[117,1202,270],{"style":123},[117,1204,1205,1207,1209],{"class":119,"style":120},[117,1206,275],{"style":123},[117,1208,300],{"style":127},[117,1210,270],{"style":123},[117,1212,1213],{"class":119,"style":120},[117,1214,598],{"style":127},[11,1216,1217,1218,1220,1221,1224,1225,1228,1229,54],{},"Create the function at ",[14,1219,1181],{},", resolved from the generated hooks folder (here ",[14,1222,1223],{},"src\u002Fgen\u002Fhooks\u002FuseCustomHookOptions.ts","). Each hook passes ",[14,1226,1227],{},"{ hookName, operationId }",". The generated barrel re-exports ",[14,1230,1231],{},"HookOptions",[108,1233,1235],{"language":110,"filename":1223,"code":1234,"class":112},"import type { HookOptions } from '.\u002FHookOptions'\n\nexport function useCustomHookOptions(\n  { hookName }: { hookName: keyof HookOptions; operationId: string },\n) {\n  if (hookName === 'useGetPetById') {\n    return { staleTime: 60_000 } satisfies HookOptions['useGetPetById']\n  }\n  return {}\n}",[14,1236,1237,143,1256,143,1258,143,1271,143,1308,143,1313,143,1332,143,1361,143,1366,143,1375],{"class":115},[117,1238,1239,1241,1244,1246,1249,1251,1253],{"class":119,"style":120},[117,1240,124],{"style":123},[117,1242,1243],{"style":131},"type ",[117,1245,128],{"style":127},[117,1247,1248],{"style":173},"HookOptions ",[117,1250,135],{"style":127},[117,1252,138],{"style":123},[117,1254,1255],{"style":141},"'.\u002FHookOptions'",[117,1257],{"class":119,"style":120},[117,1259,1260,1263,1266,1269],{"class":119,"style":120},[117,1261,1262],{"style":123},"export ",[117,1264,1265],{"style":123},"function ",[117,1267,1268],{"style":173},"useCustomHookOptions",[117,1270,247],{"style":127},[117,1272,1273,1275,1278,1280,1282,1284,1287,1289,1292,1294,1297,1299,1301,1304,1306],{"class":119,"style":120},[117,1274,252],{"style":127},[117,1276,1277],{"style":131},"hookName ",[117,1279,300],{"style":127},[117,1281,181],{"style":123},[117,1283,128],{"style":127},[117,1285,1286],{"style":127},"hookName",[117,1288,181],{"style":123},[117,1290,1291],{"style":123},"keyof ",[117,1293,1231],{"style":173},[117,1295,1296],{"style":123},"; ",[117,1298,740],{"style":127},[117,1300,181],{"style":131},[117,1302,1303],{"style":173},"string ",[117,1305,300],{"style":127},[117,1307,270],{"style":123},[117,1309,1310],{"class":119,"style":120},[117,1311,1312],{"style":127},") {",[117,1314,1315,1317,1320,1322,1324,1327,1330],{"class":119,"style":120},[117,1316,275],{"style":127},[117,1318,1319],{"style":123},"if ",[117,1321,247],{"style":127},[117,1323,1277],{"style":131},[117,1325,1326],{"style":123},"=== ",[117,1328,1329],{"style":141},"'useGetPetById'",[117,1331,1312],{"style":127},[117,1333,1334,1336,1339,1341,1343,1345,1347,1349,1352,1354,1356,1358],{"class":119,"style":120},[117,1335,283],{"style":127},[117,1337,1338],{"style":123},"return ",[117,1340,128],{"style":127},[117,1342,292],{"style":127},[117,1344,181],{"style":123},[117,1346,297],{"style":127},[117,1348,135],{"style":127},[117,1350,1351],{"style":123},"satisfies ",[117,1353,1231],{"style":173},[117,1355,722],{"style":127},[117,1357,1329],{"style":141},[117,1359,1360],{"style":127},"]",[117,1362,1363],{"class":119,"style":120},[117,1364,1365],{"style":127},"  }",[117,1367,1368,1370,1372],{"class":119,"style":120},[117,1369,275],{"style":127},[117,1371,1338],{"style":123},[117,1373,1374],{"style":127},"{}",[117,1376,1377],{"class":119,"style":120},[117,1378,300],{"style":127},[11,1380,1381],{},"Per-call query options override shared options.",{"title":1383,"searchDepth":1384,"depth":1384,"links":1385},"",5,[1386,1388,1389,1390,1391,1392,1393,1394],{"id":88,"depth":1387,"text":89},2,{"id":339,"depth":1387,"text":340},{"id":481,"depth":1387,"text":482},{"id":631,"depth":1387,"text":632},{"id":659,"depth":1387,"text":660},{"id":763,"depth":1387,"text":764},{"id":1002,"depth":1387,"text":1003},{"id":1115,"depth":1387,"text":1116},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-react-query\u002Fguides\u002Fcalling-operations",1793639048178]