Improve "Testing Relay with Preloaded Queries" docs
- Dominant language
- Rust
- Stars
- 19k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I followed all steps to test the `useQueryLoader` and `usePreloadedQuery` hooks, and it took me some hours to make it work. Finally, after some debugging, I found that the problem was because I needed to pass all unused variables to `loadQuery` as `null.`
This is my query:
```ts
export const usersQuery = graphql`
query UsersQuery(
$filters: UsersQueryFilters
$first: Int
$after: String
$last: Int
$before: String
) {
...UsersList_query
@arguments(
filters: $filters
first: $first
after: $after
last: $last
before: $before
)
}
`;
```
and I was passing these variables to `loadQuery`:
```ts
{
filters: { name: 'John', age: 30 },
first: 10,
};
```
After logging the operation, I saw that `after,` `last,` and `before` were `null.` So I called `loadQuery` this way, and it worked:
```ts
{
filters: { name: 'John', age: 30 },
first: 10,
after: null,
last: null,
before: null,
};
```
I suggest adding a warning after the second bullet on docs always pointing to pass variables as `null` if they're `undefined.`

Contributor guide
Assessment
This issue has not been assessed yet.