Skip to content

Commit

Permalink
docs(angular-query): improve queryOptions code snippets (#8601)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoud-dv authored Feb 2, 2025
1 parent ebe996d commit 7ff544e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions docs/framework/angular/guides/query-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,28 @@ export class QueriesService {

// usage:

postId = input.required({
transform: numberAttribute,
})
queries = inject(QueriesService)

injectQuery(this.queries.post(1))
injectQueries({
queries: [this.queries.post(1), this.queries.post(2)],
})
postQuery = injectQuery(() => this.queries.post(this.postId()))

queryClient.prefetchQuery(this.queries.post(23))
queryClient.setQueryData(this.queries.post(42).queryKey, newGroups)
queryClient.setQueryData(this.queries.post(42).queryKey, newPost)
```

[//]: # 'Example1'
[//]: # 'Example2'

```ts
// Type inference still works, so query.data will be the return type of select instead of queryFn
queries = inject(QueriesService)

query = injectQuery(() => ({
...groupOptions(1),
select: (data) => data.title,
}))
```

[//]: # 'Example2'

0 comments on commit 7ff544e

Please sign in to comment.