Skip to content

Commit bd78991

Browse files
committed
AI suggestions
1 parent 839cffd commit bd78991

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

docs/source/data/queries.mdx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ For more information, see [Handling operation errors](./error-handling/).
254254

255255
When React renders a component that calls `useQuery`, Apollo Client automatically executes the corresponding query. But what if you want to execute a query in response to a user interaction, such as a user clicking a button?
256256

257-
The [`useLazyQuery`](../api/react/useLazyQuery) hook is suited for manually executing queries. Unlike `useQuery`, when you use `useLazyQuery`, it does not immediately execute its associated query. Instead, it returns an execution function that you call whenever you need to execute the query.
257+
The [`useLazyQuery`](../api/react/useLazyQuery) hook is for manually executing queries. Unlike `useQuery`, when you use `useLazyQuery`, it doesn't immediately execute its associated query. Instead, it returns an execution function that you call whenever you need to execute the query.
258258

259259
Here's an example:
260260

@@ -283,7 +283,7 @@ The first item in `useLazyQuery`'s return tuple is the execution function, and t
283283
284284
### Re-rendering with new options
285285
286-
Unlike `useQuery`, options provided to `useLazyQuery` that change on re-renders do not automatically execute the query. Instead, `useLazyQuery` waits to execute the query using the updated options until the execution function is called again.
286+
Unlike `useQuery`, options provided to `useLazyQuery` that change on re-renders do not automatically execute the query. Instead, `useLazyQuery` waits to execute the query with the updated options until you call the execution function again.
287287
288288
The following is an example that changes the fetch policy depending on whether the user is online or offline:
289289
@@ -306,15 +306,15 @@ function GetDogs({ isOnline }) {
306306
307307
<Note>
308308
309-
The changed options are immediately applied to the underlying `ObservableQuery` (accessible by the `observable` property) even though the query is not executed. Inspecting the options on the `observable` returns the updated options. This means the updated options will be used for other APIs (such as `refetch`), even before calling the execution function again.
309+
The changed options are immediately applied to the underlying `ObservableQuery` (accessible by the `observable` property) even though the query isn't executed. Inspecting the options on the `observable` returns the updated options. This means the updated options are used for other APIs (such as `refetch`), even before you call the execution function again.
310310
311311
</Note>
312312
313313
### Working with variables
314314
315315
You provide `variables` to the execution function when executing the query.
316316
317-
The following is an example that gets a specific dog's photo when clicking the "Get photo" button:
317+
The following example gets a specific dog's photo when you click the **Get photo** button:
318318
319319
```jsx
320320
function DogPhoto() {
@@ -336,15 +336,15 @@ function DogPhoto() {
336336
337337
<Note>
338338
339-
When using TypeScript, the `variables` option is required along with any required variables when the query provided to `useLazyQuery` contains required variables. If the options argument is not provided to the execution function, or the `variables` option is missing required variables, you see a TypeScript error.
339+
When using TypeScript, the `variables` option is required if the query provided to `useLazyQuery` contains required variables. If the options argument isn't provided to the execution function, or the `variables` option is missing required variables, TypeScript raises an error.
340340
341341
</Note>
342342
343343
#### Changing variables
344344
345345
You change variables by calling the execution function with updated variables.
346346
347-
The following is an example that gets the selected dog's photo when clicking the "Get photo" button.
347+
The following example gets the selected dog's photo when you click the **Get photo** button.
348348
349349
```jsx
350350
function DogPhoto() {
@@ -377,7 +377,7 @@ If you need to reference the currently executed query's variables, use the `vari
377377
378378
<Tip>
379379
380-
The `variables` property is empty until the execution function is called for the first time. Use the `called` property returned by `useLazyQuery` to determine if the execution function has been called at least once.
380+
The `variables` property is empty until you call the execution function for the first time. Use the `called` property returned by `useLazyQuery` to determine if you've called the execution function at least once.
381381
382382
</Tip>
383383
@@ -429,7 +429,7 @@ Use the `data`, `error`, and other properties returned by `useLazyQuery` to sync
429429
430430
In cases where you don't need to keep your component in sync with query state, use `client.query()` directly because it won't unnecessarily render your component for data that you don't use.
431431
432-
Using `useLazyQuery` in those situations should be considered an antipattern.
432+
Using `useLazyQuery` in these situations is an antipattern.
433433
434434
<ExpansionPanel title="Example">
435435
@@ -498,7 +498,7 @@ const handleClick = async () => {
498498
499499
<Note>
500500
501-
`data` might not contain any partial data and is instead set to `undefined`. This typically occurs when a [network error](./error-handling#network-errors) causes the query to fail because the error might not be associated with GraphQL execution.
501+
The `data` property might be `undefined` instead of containing partial data. This typically occurs when a [network error](./error-handling#network-errors) causes the query to fail, because the error isn't associated with GraphQL execution.
502502
503503
</Note>
504504
@@ -518,21 +518,21 @@ const handleClick = async () => {
518518
519519
<Tip>
520520
521-
`data` might be `undefined` in the event a [network error](./error-handling#network-errors) is raised. We recommend checking if `data` is `undefined` before attempting to use it in case an error occurs during query execution.
521+
`data` might be `undefined` if a [network error](./error-handling#network-errors) occurs. Check if `data` is `undefined` before you use it, in case an error occurs during query execution.
522522
523523
</Tip>
524524
525525
#### Retaining query results
526526
527-
In-flight queries executed by `useLazyQuery` are aborted when the component unmounts or another query is started when calling the execution function, causing the promise to reject. In some cases, you might find this behavior undesirable and would prefer to let the query run to completion.
527+
Apollo Client aborts in-flight queries executed by `useLazyQuery` when the component unmounts or when you start another query by calling the execution function. This causes the promise to reject. In some cases, you might find this behavior undesirable and prefer to let the query run to completion.
528528
529529
<Note>
530530
531-
Apollo Client ensures the rejected promise doesn't throw an unhandled rejection error when you don't add a rejection handler to the promise. This however means that aborted errors are silent and might go unnoticed. If you want to be notified when the request is aborted, provide a rejection handler for the promise.
531+
Apollo Client ensures the rejected promise doesn't throw an unhandled rejection error when you don't add a rejection handler to the promise. However, this means that aborted errors are silent and might go unnoticed. If you want to be notified when the request is aborted, provide a rejection handler for the promise.
532532
533533
</Note>
534534
535-
The promise returned by the execution function includes a `.retain()` method. When called, it ensures the query continues running even when the component unmounts or a new query is started before the last one finished.
535+
The promise returned by the execution function includes a `.retain()` method. When you call it, it ensures the query continues running even if the component unmounts or you start a new query before the previous one finishes.
536536
537537
```jsx
538538
function GetDogs() {
@@ -553,7 +553,7 @@ function GetDogs() {
553553
}
554554
```
555555
556-
The `retain()` method returns the original promise. The previous example can be shortened to a single line:
556+
The `retain()` method returns the original promise, so you can shorten the previous example to a single line:
557557
558558
```ts
559559
const { data } = await getDogs().retain();

0 commit comments

Comments
 (0)