-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into release-3.4.
- Loading branch information
Showing
31 changed files
with
8,686 additions
and
5,706 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
```js:title=index.js | ||
import { ApolloClient, InMemoryCache, HttpLink, from } from "@apollo/client"; | ||
import { onError } from "@apollo/client/link/error"; | ||
|
||
const httpLink = new HttpLink({ | ||
uri: "http://localhost:4000/graphql" | ||
}); | ||
|
||
const errorLink = onError(({ graphQLErrors, networkError }) => { | ||
if (graphQLErrors) | ||
graphQLErrors.forEach(({ message, locations, path }) => | ||
console.log( | ||
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`, | ||
), | ||
); | ||
|
||
if (networkError) console.log(`[Network error]: ${networkError}`); | ||
}); | ||
|
||
// If you provide a link chain to ApolloClient, you | ||
// don't provide the `uri` option. | ||
const client = new ApolloClient({ | ||
// The `from` function combines an array of individual links | ||
// into a link chain | ||
link: from([errorLink, httpLink]), | ||
cache: new InMemoryCache() | ||
}); | ||
``` |
Oops, something went wrong.