Skip to content

Commit 0363310

Browse files
committed
docs: client headers & composables
1 parent c31b239 commit 0363310

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

docs/content/1.getting-started/2.composables.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,52 @@ useGqlCors({ credentials: 'same-origin' })
1616
Add Authorization header to subsequent requests.
1717

1818
### Bearer token
19+
1920
```ts
2021
useGqlToken('secret_token')
21-
```
2222

23-
Add `Bearer` token to a specific client
24-
```ts
23+
// Add `Bearer` token to a specific client
2524
useGqlToken('my_github_token', { client: 'github' })
2625
```
2726

2827
### Custom token
28+
2929
```ts
30-
useGqlToken('secret_token', {
30+
useGqlToken({
31+
token: 'secret_token',
3132
config: {
3233
type: 'Bearer',
3334
name: 'X-Custom-Auth'
3435
}
3536
})
3637
```
3738

39+
### Clear token
40+
41+
```ts
42+
// Clear token from default client
43+
useGqlToken(null)
44+
45+
// Clear token from a specific client
46+
useGqlToken({ token: null, client: '<client>' })
47+
```
48+
3849
## useGqlHeaders
3950

4051
Add the specified headers to subsequent requests.
4152

4253
```ts
4354
useGqlHeaders({ 'X-Custom-Header': 'value' })
55+
56+
// Add headers to a specific client.
57+
useGqlHeaders({ 'X-CSRF-TOKEN': 'value' }, 'client-name')
4458
```
4559

46-
Add headers to a specific client.
60+
### Reset headers
61+
4762
```ts
48-
useGqlHeaders({ 'X-CSRF-TOKEN': 'value' }, 'client-name')
63+
useGqlHeaders(null)
64+
65+
// Reset headers for a specific client.
66+
useGqlHeaders({ headers: null, client: '<client>' })
4967
```

docs/content/1.getting-started/3.configuration.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ When enabled, this flag will force tokens set at config-level to be retained cli
115115

116116
By default, tokens set by `runtimeConfig` or `environment variables` only live server-side (for Code Generation & SSR requests).
117117

118+
[More information here](/advanced/authentication#retain-token-on-client-side)
119+
118120
### `proxyCookies`
119121

120122
Pass cookies from the browser to the GraphQL API in SSR mode.
@@ -123,4 +125,7 @@ Pass cookies from the browser to the GraphQL API in SSR mode.
123125
Enabled by default.
124126
::
125127

126-
[More information here](/advanced/authentication#retain-token-on-client-side)
128+
### `headers`
129+
130+
Configure default headers to be sent with each request.
131+

0 commit comments

Comments
 (0)