Skip to content

Commit 9b6d831

Browse files
committed
split hooks up into individual api pages
1 parent ca541ae commit 9b6d831

24 files changed

+430
-318
lines changed

docs/source/_sidebar.yaml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,39 @@ items:
135135
href: ./api/core/ObservableQuery
136136
- label: React
137137
children:
138-
- label: Hooks
139-
href: ./api/react/hooks
140-
- label: Preloading
138+
- label: ApolloProvider
139+
href: ./api/react/ApolloProvider
140+
- label: ApolloConsumer
141+
href: ./api/react/ApolloConsumer
142+
- label: useQuery
143+
href: ./api/react/useQuery
144+
- label: useLazyQuery
145+
href: ./api/react/useLazyQuery
146+
- label: useMutation
147+
href: ./api/react/useMutation
148+
- label: useSubscription
149+
href: ./api/react/useSubscription
150+
- label: useFragment
151+
href: ./api/react/useFragment
152+
- label: useApolloClient
153+
href: ./api/react/useApolloClient
154+
- label: useReactiveVar
155+
href: ./api/react/useReactiveVar
156+
- label: useSuspenseQuery
157+
href: ./api/react/useSuspenseQuery
158+
- label: useBackgroundQuery
159+
href: ./api/react/useBackgroundQuery
160+
- label: useReadQuery
161+
href: ./api/react/useReadQuery
162+
- label: useLoadableQuery
163+
href: ./api/react/useLoadableQuery
164+
- label: useQueryRefHandlers
165+
href: ./api/react/useQueryRefHandlers
166+
- label: skipToken
167+
href: ./api/react/skipToken
168+
- label: createQueryPreloader
141169
href: ./api/react/preloading
142-
- label: Testing
170+
- label: MockProvider
143171
href: ./api/react/testing
144172
- label: SSR
145173
href: ./api/react/ssr

docs/source/api/cache/InMemoryCache.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: class InMemoryCache
33
description: API reference
4-
api_reference: true
54
---
65

76
{/** @import {MDXProvidedComponents} from '../../../shared/MdxProvidedComponents.js' */}

docs/source/api/core/ApolloClient.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: class ApolloClient
33
description: API reference
44
order: 11
5-
api_reference: true
65
---
76

87
{/** @import {MDXProvidedComponents} from '../../../shared/MdxProvidedComponents.js' */}

docs/source/api/core/ObservableQuery.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: ObservableQuery
33
description: API reference
4-
api_reference: true
54
---
65

76
{/** @import {MDXProvidedComponents} from '../../../shared/MdxProvidedComponents.js' */}

docs/source/api/link/apollo-link-subscriptions.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: Subscriptions Link
33
description: Execute subscriptions (or other operations) over WebSocket with the graphql-ws library
4-
api_reference: true
54
---
65

76
> We recommend reading [Apollo Link overview](./introduction/) before learning about individual links.

docs/source/api/link/apollo-link-ws.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: WebSocket Link
33
description: Execute subscriptions (or other operations) over WebSocket with the subscriptions-transport-ws library
4-
api_reference: true
54
---
65

76
> ⚠️ **We no longer recommend using `WebSocketLink` or the `subscriptions-transport-ws` library**, because the library is not actively maintained. To execute subscriptions, We instead recommend using the newer `graphql-ws` library with the accompanying [`GraphQLWsLink`](./apollo-link-subscriptions).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: ApolloConsumer
3+
description: Apollo Client API reference
4+
---
5+
6+
7+
## The `ApolloConsumer` component
8+
9+
One way to access the configured Apollo Client instance directly is to create an `ApolloConsumer` component and provide a render prop function as its child. The render prop function will be called with your `ApolloClient` instance as its only argument. You can think of the `ApolloConsumer` component as similar to the `Consumer` component from the [React Context API](https://react.dev/reference/react/useContext).
10+
11+
### Example
12+
13+
```jsx
14+
import { ApolloConsumer } from '@apollo/client/react';
15+
16+
function WithApolloClient() {
17+
return (
18+
<ApolloConsumer>
19+
{client => 'We have access to the client!' /* do stuff here */}
20+
</ApolloConsumer>
21+
);
22+
}
23+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: ApolloProvider
3+
description: Apollo Client API reference
4+
---
5+
6+
{/** @import {MDXProvidedComponents} from '../../../shared/MdxProvidedComponents.js' */}
7+
8+
## The `ApolloProvider` component
9+
10+
The `ApolloProvider` component leverages [React's Context API](https://react.dev/reference/react/useContext) to make a configured Apollo Client instance available throughout a React component tree. This component can be imported directly from the `@apollo/client/react` package.
11+
12+
```js
13+
import { ApolloProvider } from '@apollo/client/react';
14+
```
15+
16+
### Props
17+
18+
| Option | Type | Description |
19+
| -------- | -------------------------- | --------------------------- |
20+
| `client` | `ApolloClient` | An `ApolloClient` instance. |
21+
22+
### Example
23+
24+
```jsx {7-9}
25+
const client = new ApolloClient({
26+
cache: new InMemoryCache(),
27+
link: new HttpLink({
28+
uri: "http://localhost:4000/graphql",
29+
})
30+
});
31+
32+
ReactDOM.render(
33+
<ApolloProvider client={client}>
34+
<MyRootComponent />
35+
</ApolloProvider>,
36+
document.getElementById('root'),
37+
);
38+
```

0 commit comments

Comments
 (0)