You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/src/guide-composable/error-handling.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -55,10 +55,10 @@ export default {
55
55
56
56
## Network Errors
57
57
58
-
When using Apollo Link, the ability to handle network errors is way more powerful. The best way to do this is to use the `apollo-link-error` to catch and handle server errors, network errors, and GraphQL errors. If you would like to combine with other links, see [composing links](https://www.apollographql.com/docs/link/composition).
58
+
When using Apollo Link, the ability to handle network errors is way more powerful. The best way to do this is to use the `@apollo/client/link/error` to catch and handle server errors, network errors, and GraphQL errors. If you would like to combine with other links, see [composing links](https://www.apollographql.com/docs/link/composition).
Copy file name to clipboardExpand all lines: packages/docs/src/guide-composable/fragments.md
+9-87
Original file line number
Diff line number
Diff line change
@@ -203,105 +203,27 @@ query {
203
203
}
204
204
```
205
205
206
-
In the query above, `allPeople` returns a result of type `Character[]`. Both `Jedi` and `Droid` are possible concrete types of `Character`, but on the client there is no way to know that without having some information about the schema. By default, Apollo Client's cache will use a heuristic fragment matcher, which assumes that a fragment matched if the result included all the fields in its selection set, and didn't match when any field was missing. This works in most cases, but it also means that Apollo Client cannot check the server response for you, and it cannot tell you when you're manually writing invalid data into the store using `update`, `updateQuery`, `writeQuery`, etc. Also, the heuristic fragment matcher will not work accurately when using fragments with unions or interfaces. Apollo Client will let you know this with a console warning (in development), if it attempts to use the default heuristic fragment matcher with unions/interfaces. The `IntrospectionFragmentMatcher` is the solution for working with unions/interfaces, and is explained in more detail below.
206
+
In the query above, `allPeople` returns a result of type `Character[]`. Both `Jedi` and `Droid` are possible concrete types of `Character`, but on the client there is no way to know that without having some information about the schema. By default, Apollo Client's cache will use a heuristic fragment matcher, which assumes that a fragment matched if the result included all the fields in its selection set, and didn't match when any field was missing. This works in most cases, but it also means that Apollo Client cannot check the server response for you, and it cannot tell you when you're manually writing invalid data into the store using `update`, `updateQuery`, `writeQuery`, etc. To inform the cache store about these polymorphic relationships, you need to pass `possibleTypes` option to `InMemoryCache` below.
207
207
208
208
The section below explains how to pass the necessary schema knowledge to the Apollo Client cache so unions and interfaces can be accurately matched and results validated before writing them into the store.
209
209
210
-
To support result validation and accurate fragment matching on unions and interfaces, a special fragment matcher called the `IntrospectionFragmentMatcher` can be used. If there are any changes related to union or interface types in your schema, you will have to update the fragment matcher accordingly.
211
-
212
-
We recommend setting up a build step that extracts the necessary information from the schema into a JSON file, where it can be imported from when constructing the fragment matcher. To set it up, follow the three steps below:
210
+
We recommend setting up a build step that extracts the necessary information from the schema into a JSON file, where it can be imported from when constructing the cache. To set it up, follow the steps below:
213
211
214
212
1. Query your server / schema to obtain the necessary information about unions and interfaces and write it to a file.
215
213
216
-
You can automate this or set this as a script to run at build time.
217
-
218
-
If you want to auto-generate the introspection result, there's a tool called [GraphQL Code Generator](https://graphql-code-generator.com) that does it. Define where your GraphQL Schema is available and where to write the file:
219
-
220
-
```yaml
221
-
# codegen.yml
222
-
schema: YOUR_API
223
-
overwrite: true
224
-
generates:
225
-
./fragmentTypes.json:
226
-
plugins:
227
-
- fragment-matcher
228
-
```
229
-
230
-
With all of that, you simply run:
231
-
232
-
```shell
233
-
gql-gen
234
-
```
235
-
236
-
> To learn more, you can read the ["Fragment Matcher" chapter](https://graphql-code-generator.com/docs/plugins/fragment-matcher).
237
-
238
-
In order to introspect the server manually, set this as a script to run at build time.
239
-
240
-
```js
241
-
constfetch=require('node-fetch')
242
-
constfs=require('fs')
243
-
244
-
fetch(`${YOUR_API_HOST}/graphql`, {
245
-
method:'POST',
246
-
headers: { 'Content-Type':'application/json' },
247
-
body:JSON.stringify({
248
-
variables: {},
249
-
query:`
250
-
{
251
-
__schema {
252
-
types {
253
-
kind
254
-
name
255
-
possibleTypes {
256
-
name
257
-
}
258
-
}
259
-
}
260
-
}
261
-
`,
262
-
}),
263
-
})
264
-
.then(result=>result.json())
265
-
.then(result=> {
266
-
// here we're filtering out any type information unrelated to unions or interfaces
2. Create a new IntrospectionFragment matcher by passing in the `fragmentTypes.json` file you just created. You'll want to do this in the same file where you initialize the cache for Apollo Client.
214
+
Read the documentation about how to [extract possibleTypes automatically](https://www.apollographql.com/docs/react/data/fragments/#generating-possibletypes-automatically) using an introspection query. Or use the plugin [fragment-matcher](https://graphql-code-generator.com/docs/plugins/fragment-matcher) for graphql-codegen and configure it for [apollo client 3](https://graphql-code-generator.com/docs/plugins/fragment-matcher#usage-with-apollo-client-3).
3. Pass in the newly created `IntrospectionFragmentMatcher` to configure your cache during construction. Then, you pass your newly configured cache to `ApolloClient` to complete the process.
216
+
2. Use `possibleTypes.json` to configure your cache during construction. Then, you pass your newly configured cache to `ApolloClient` to complete the process.
Copy file name to clipboardExpand all lines: packages/docs/src/guide-composable/subscription.md
+7-20
Original file line number
Diff line number
Diff line change
@@ -53,26 +53,14 @@ A future version of Apollo or GraphQL might include support for live queries, wh
53
53
54
54
## Client setup
55
55
56
-
The most popular transport for GraphQL subscriptions today is [`subscriptions-transport-ws`](https://github.com/apollographql/subscriptions-transport-ws). This package is maintained by the Apollo community, but can be used with any client or server GraphQL implementation. In this article, we'll explain how to set it up on the client, but you'll also need a server implementation. You can [read about how to use subscriptions with a JavaScript server](https://www.apollographql.com/docs/graphql-subscriptions/setup), or enjoy subscriptions set up out of the box if you are using a GraphQL backend as a service like [Graphcool](https://www.graph.cool/docs/tutorials/worldchat-subscriptions-example-ui0eizishe/).
56
+
In this article, we'll explain how to set it up on the client, but you'll also need a server implementation. You can [read about how to use subscriptions with a JavaScript server](https://www.apollographql.com/docs/graphql-subscriptions/setup), or enjoy subscriptions set up out of the box if you are using a GraphQL backend as a service like [Graphcool](https://www.graph.cool/docs/tutorials/worldchat-subscriptions-example-ui0eizishe/).
57
57
58
58
Let's look at how to add support for this transport to Apollo Client.
59
59
60
-
First, install the WebSocket Apollo Link (`apollo-link-ws`) from npm:
In many cases it is necessary to authenticate clients before allowing them to receive subscription results. To do this, the `SubscriptionClient` constructor accepts a `connectionParams` field, which passes a custom object that the server can use to validate the connection before setting up any subscriptions.
Copy file name to clipboardExpand all lines: packages/docs/src/guide/installation.md
+3-38
Original file line number
Diff line number
Diff line change
@@ -16,55 +16,20 @@ Then you can skip to next section: [Basic Usage](./apollo/).
16
16
17
17
## Manual installation
18
18
19
-
You can either use [Apollo Boost](#apollo-boost) or [Apollo Client directly](#apollo-client-full-configuration) (more configuration work).
20
-
21
-
### Apollo Boost
22
-
23
-
Apollo Boost is a zero-config way to start using Apollo Client. It includes some sensible defaults, such as our recommended `InMemoryCache` and `HttpLink`, which come configured for you with our recommended settings and it's perfect for starting to develop fast.
Copy file name to clipboardExpand all lines: packages/docs/src/migration/README.md
+16-14
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# From vue-apollo 2 and Apollo 1
1
+
# From vue-apollo 3
2
2
3
3
The main changes are related to the apollo client setup. Your components code shouldn't be affected. Apollo now uses a more flexible [apollo-link](https://github.com/apollographql/apollo-link) system that allows compositing multiple links together to add more features (like batching, offline support and more).
4
4
@@ -9,13 +9,13 @@ The main changes are related to the apollo client setup. Your components code sh
0 commit comments