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: .changeset/eleven-news-lay.md
+62Lines changed: 62 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,3 +8,65 @@
8
8
---
9
9
10
10
Add `@defer` directive support
11
+
12
+
When a query includes a deferred fragment field, the server will return a partial response with the non-deferred fields first, followed by the remaining fields once they have been resolved.
13
+
14
+
Once start using the `@defer` directive in your queries, the generated code will automatically include support for the directive.
15
+
16
+
```jsx
17
+
// src/index.tsx
18
+
import { graphql } from'./gql'
19
+
constOrdersFragment=graphql(`
20
+
fragment OrdersFragment on User {
21
+
orders {
22
+
id
23
+
total
24
+
}
25
+
}
26
+
`)
27
+
constGetUserQuery=graphql(`
28
+
query GetUser($id: ID!) {
29
+
user(id: $id) {
30
+
id
31
+
name
32
+
...OrdersFragment @defer
33
+
}
34
+
}
35
+
`)
36
+
```
37
+
38
+
The generated type for `GetUserQuery` will have information that the fragment is _incremental,_ meaning it may not be available right away.
Apart from generating code that includes support for the `@defer` directive, the Codegen also exports a utility function called `isFragmentReady`. You can use it to conditionally render components based on whether the data for a deferred
0 commit comments