[{"data":1,"prerenderedAt":447},["ShallowReactive",2],{"navigation_docs":3,"-getting-started-auth-helpers":43,"-getting-started-auth-helpers-surround":442},[4,26],{"title":5,"path":6,"stem":7,"children":8,"page":25},"Getting Started","/getting-started","1.getting-started",[9,13,17,21],{"title":10,"path":11,"stem":12},"Quick Start","/getting-started/quick-start","1.getting-started/1.quick-start",{"title":14,"path":15,"stem":16},"Configuration","/getting-started/configuration","1.getting-started/2.configuration",{"title":18,"path":19,"stem":20},"Composables","/getting-started/composables","1.getting-started/3.composables",{"title":22,"path":23,"stem":24},"Auth Helpers","/getting-started/auth-helpers","1.getting-started/4.auth-helpers",false,{"title":27,"path":28,"stem":29,"children":30,"page":25},"Recipes","/recipes","2.recipes",[31,35,39],{"title":32,"path":33,"stem":34},"Authentication","/recipes/authentication","2.recipes/1.authentication",{"title":36,"path":37,"stem":38},"Error Policy","/recipes/error-handling","2.recipes/2.error-handling",{"title":40,"path":41,"stem":42},"TypesScript support","/recipes/typescript-support","2.recipes/3.typescript-support",{"id":44,"title":22,"body":45,"description":55,"extension":437,"links":438,"meta":439,"navigation":132,"path":23,"seo":440,"stem":24,"__hash__":441},"docs/1.getting-started/4.auth-helpers.md",{"type":46,"value":47,"toc":423},"minimark",[48,52,56,59,62,70,73,88,182,189,199,205,208,219,289,294,325,331,334,391,396,419],[49,50,22],"h1",{"id":51},"auth-helpers",[53,54,55],"p",{},"Helper functions for working with authentication in Apollo.",[57,58],"hr",{},[53,60,61],{},"Nuxt Apollo provides three (3) auth helpers which can be easily plugged into your authentication flow to interface with configured Apollo clients.",[63,64,66],"h2",{"id":65},"gettoken",[67,68,69],"code",{},"getToken",[53,71,72],{},"Retrieve the auth token token for the specified client.",[53,74,75,76,84,85,87],{},"This adheres to the ",[77,78,80,83],"a",{"href":79},"/recipes/authentication#auth-hook",[67,81,82],{},"apollo:auth"," hook",". and will attempt to automatically retrieve the token from the ",[67,86,82],{}," hook.",[89,90,95],"pre",{"className":91,"code":92,"language":93,"meta":94,"style":94},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const { getToken } = useApollo()\n\nconst token = getToken()\n\nconst otherToken = getToken('\u003Cclient_name>')\n","ts","",[67,96,97,127,134,150,155],{"__ignoreMap":94},[98,99,102,106,110,114,117,120,124],"span",{"class":100,"line":101},"line",1,[98,103,105],{"class":104},"spNyl","const",[98,107,109],{"class":108},"sMK4o"," {",[98,111,113],{"class":112},"sTEyZ"," getToken ",[98,115,116],{"class":108},"}",[98,118,119],{"class":108}," =",[98,121,123],{"class":122},"s2Zo4"," useApollo",[98,125,126],{"class":112},"()\n",[98,128,130],{"class":100,"line":129},2,[98,131,133],{"emptyLinePlaceholder":132},true,"\n",[98,135,137,139,142,145,148],{"class":100,"line":136},3,[98,138,105],{"class":104},[98,140,141],{"class":112}," token ",[98,143,144],{"class":108},"=",[98,146,147],{"class":122}," getToken",[98,149,126],{"class":112},[98,151,153],{"class":100,"line":152},4,[98,154,133],{"emptyLinePlaceholder":132},[98,156,158,160,163,165,167,170,173,177,179],{"class":100,"line":157},5,[98,159,105],{"class":104},[98,161,162],{"class":112}," otherToken ",[98,164,144],{"class":108},[98,166,147],{"class":122},[98,168,169],{"class":112},"(",[98,171,172],{"class":108},"'",[98,174,176],{"class":175},"sfazB","\u003Cclient_name>",[98,178,172],{"class":108},[98,180,181],{"class":112},")\n",[183,184,186,188],"h3",{"id":185},"gettoken-reference",[67,187,69],{}," Reference",[190,191,192],"ul",{},[193,194,195,198],"li",{},[67,196,197],{},"client",": The Apollo client who's token should be retrieved.",[63,200,202],{"id":201},"onlogin",[67,203,204],{},"onLogin",[53,206,207],{},"Used to apply the given auth token to the specified Apollo client. This is required if your GraphQL API expects authentication to be passed via a HTTP header.",[53,209,210,211,214,215,218],{},"By default, this function will reset the Apollo client cache and re-execute all queries, this behavior can be averted by passing ",[67,212,213],{},"false"," as the third parameter (",[67,216,217],{},"skipResetStore",").",[89,220,222],{"className":91,"code":221,"language":93,"meta":94,"style":94},"const { onLogin } = useApollo()\n\nfunction handleLogin() {\n  // your login flow...\n\n  onLogin(token)\n}\n",[67,223,224,241,245,259,265,269,283],{"__ignoreMap":94},[98,225,226,228,230,233,235,237,239],{"class":100,"line":101},[98,227,105],{"class":104},[98,229,109],{"class":108},[98,231,232],{"class":112}," onLogin ",[98,234,116],{"class":108},[98,236,119],{"class":108},[98,238,123],{"class":122},[98,240,126],{"class":112},[98,242,243],{"class":100,"line":129},[98,244,133],{"emptyLinePlaceholder":132},[98,246,247,250,253,256],{"class":100,"line":136},[98,248,249],{"class":104},"function",[98,251,252],{"class":122}," handleLogin",[98,254,255],{"class":108},"()",[98,257,258],{"class":108}," {\n",[98,260,261],{"class":100,"line":152},[98,262,264],{"class":263},"sHwdD","  // your login flow...\n",[98,266,267],{"class":100,"line":157},[98,268,133],{"emptyLinePlaceholder":132},[98,270,272,275,278,281],{"class":100,"line":271},6,[98,273,274],{"class":122},"  onLogin",[98,276,169],{"class":277},"swJcz",[98,279,280],{"class":112},"token",[98,282,181],{"class":277},[98,284,286],{"class":100,"line":285},7,[98,287,288],{"class":108},"}\n",[183,290,292,188],{"id":291},"onlogin-reference",[67,293,204],{},[190,295,296,301,314],{},[193,297,298,300],{},[67,299,280],{},": The token to be applied.",[193,302,303,305,306],{},[67,304,197],{},": The Apollo client to authenticate.",[190,307,308],{},[193,309,310,311],{},"Default: ",[67,312,313],{},"default",[193,315,316,318,319],{},[67,317,217],{},": Whether to skip resetting the Apollo client cache.",[190,320,321],{},[193,322,310,323],{},[67,324,213],{},[63,326,328],{"id":327},"onlogout",[67,329,330],{},"onLogout",[53,332,333],{},"Used to remove the auth token from the specified Apollo client.",[89,335,337],{"className":91,"code":336,"language":93,"meta":94,"style":94},"const { onLogout } = useApollo()\n\nfunction handleLogout() {\n  // your logout flow...\n\n  onLogout()\n}\n",[67,338,339,356,360,371,376,380,387],{"__ignoreMap":94},[98,340,341,343,345,348,350,352,354],{"class":100,"line":101},[98,342,105],{"class":104},[98,344,109],{"class":108},[98,346,347],{"class":112}," onLogout ",[98,349,116],{"class":108},[98,351,119],{"class":108},[98,353,123],{"class":122},[98,355,126],{"class":112},[98,357,358],{"class":100,"line":129},[98,359,133],{"emptyLinePlaceholder":132},[98,361,362,364,367,369],{"class":100,"line":136},[98,363,249],{"class":104},[98,365,366],{"class":122}," handleLogout",[98,368,255],{"class":108},[98,370,258],{"class":108},[98,372,373],{"class":100,"line":152},[98,374,375],{"class":263},"  // your logout flow...\n",[98,377,378],{"class":100,"line":157},[98,379,133],{"emptyLinePlaceholder":132},[98,381,382,385],{"class":100,"line":271},[98,383,384],{"class":122},"  onLogout",[98,386,126],{"class":277},[98,388,389],{"class":100,"line":285},[98,390,288],{"class":108},[183,392,394,188],{"id":393},"onlogout-reference",[67,395,330],{},[190,397,398,409],{},[193,399,400,402,403],{},[67,401,197],{},": The Apollo client to de-authenticate.",[190,404,405],{},[193,406,310,407],{},[67,408,313],{},[193,410,411,318,413],{},[67,412,217],{},[190,414,415],{},[193,416,310,417],{},[67,418,213],{},[420,421,422],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}",{"title":94,"searchDepth":129,"depth":129,"links":424},[425,429,433],{"id":65,"depth":129,"text":69,"children":426},[427],{"id":185,"depth":136,"text":428},"getToken Reference",{"id":201,"depth":129,"text":204,"children":430},[431],{"id":291,"depth":136,"text":432},"onLogin Reference",{"id":327,"depth":129,"text":330,"children":434},[435],{"id":393,"depth":136,"text":436},"onLogout Reference","md",null,{},{"title":22,"description":55},"v1358bc0lXVKVG7n2CpQ0ML9n2lXyQTZrLyMpGryS90",[443,445],{"title":18,"path":19,"stem":20,"description":444,"children":-1},"Nuxt Apollo provides and Auto Imports key composables for seamless usage throughout your application.",{"title":32,"path":33,"stem":34,"description":446,"children":-1},"Configure Nuxt Apollo via the apollo property.",1785308701006]