Skip to content

Commit 57cb0db

Browse files
Pr/fix doc (#12904)
* fix: authentication docs to reflect new apollo web v4 * fix: authentication docs to reflect apollo client v4 * Update docs/source/networking/authentication.mdx --------- Co-authored-by: Lenz Weber-Tronic <[email protected]>
1 parent 60fad13 commit 57cb0db

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/source/networking/authentication.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Apollo Client uses the ultra flexible [Apollo Link](../api/link/introduction/) t
1111
If your app is browser based and you are using cookies for login and session management with a backend, tell your network interface to send the cookie along with every request. Pass the credentials option e.g. `credentials: 'same-origin'` if your backend server is the same domain, as shown below, or else `credentials: 'include'` if your backend is a different domain.
1212

1313
```js
14-
const link = createHttpLink({
14+
const link = new HttpLink({
1515
uri: "/graphql",
1616
credentials: "same-origin",
1717
});
@@ -42,14 +42,14 @@ Another common way to identify yourself when using HTTP is to send along an auth
4242
ReactJS example:
4343

4444
```js
45-
import { ApolloClient, createHttpLink, InMemoryCache } from "@apollo/client";
46-
import { setContext } from "@apollo/client/link/context";
45+
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
46+
import { SetContextLink } from "@apollo/client/link/context";
4747

48-
const httpLink = createHttpLink({
48+
const httpLink = new HttpLink({
4949
uri: "/graphql",
5050
});
5151

52-
const authLink = setContext((_, { headers }) => {
52+
const authLink = new SetContextLink(({ headers }) => {
5353
// get the authentication token from local storage if it exists
5454
const token = localStorage.getItem("token");
5555
// return the headers to the context so httpLink can read them

0 commit comments

Comments
 (0)