The naming convention behind _def and _ctx #64
-
Hi! 👋 I have a question about the naming convention behind fields such as queryClient.invalidateQueries({
queryKey: queries.todos.list._def,
refetchActive: false,
}); and here
My question is: are Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @lukaszmakuch everything exposed for you through the typesystem is supposed to be used. The only reason they start with |
Beta Was this translation helpful? Give feedback.
Hi @lukaszmakuch everything exposed for you through the typesystem is supposed to be used. The only reason they start with
_
is to differentiate that these are "internal" properties auto generated by the lib, and not something yourself has declared as an entry key (if you try to create a key starting with_
you will have a runtime error), and also to not create a deny list of common property names you can't use.These properties serve to give you access to some features like the query definition
_def
e.g., the fundamental query key to a composable query key (the_def
of['users', { userId: 1 }]
is['users']
), or to give you access to contextual queries like shown in the docs.