Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/reference/plugins/tanstack-query.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,18 @@ const onCreate = () => {
</div>
</template>
```
:::tip
If the query parameters are not constant, you need to wrap the query in a `computed` to make it reactive.
```ts
const queryParams = computed(() => ({
where: {
space: { slug: route.params.slug as string },
id: meQuery.data.value?.userId
},
}));
const { data: posts } = useFindManyPost(queryParams);
```
Comment on lines +427 to +435
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add missing imports and context in the example
The snippet references computed, route, and meQuery without showing how they’re imported or initialized, which may confuse readers. You could update the snippet to include necessary imports and a mock user‑query hook. For example:

 ```ts
+import { computed } from 'vue';
+import { useRoute } from 'vue-router';
+import { useGetCurrentUser } from '@/lib/hooks'; // adjust hook name as needed
+
+const route = useRoute();
+const userQuery = useGetCurrentUser();
 
-const queryParams = computed(() => ({
+const queryParams = computed(() => ({
     where: { 
         space: { slug: route.params.slug as string }, 
-        id: meQuery.data.value?.userId 
+        id: userQuery.data?.id 
     },
 }));
 const { data: posts } = useFindManyPost(queryParams);

This makes the example self‑contained and runnable.

:::

</TabItem>

Expand Down