Skip to content
Discussion options

You must be logged in to vote

I think you should rethink how your queries are consumed so the user.data.id is always present. As you noted, this is pretty much #283 (comment). Having enabled false still requires creating an entry so userOrders is defined. That why I believe you should rethink the way the orders query is consumed.


You can ensure a query within another query with query options (typed and great when queries or keys are used in multiple places):

import { defineQueryOptions, useQueryCache } from '@pinia/colada'

const USERS_QUERY_KEYS = {
  root: ['users'] as const,
  byId: (id: string) => [...USERS_QUERY_KEYS.root, id] as const,

  orders: (id: string) => [...USERS_QUERY_KEYS.byId(id), 'orders'] as const,
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Perdolique
Comment options

@posva
Comment options

Answer selected by Perdolique
@Perdolique
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants