Unsure how to pass optional params using the object syntax #544
Answered
by
dimitrisnl
dimitrisnl
asked this question in
General
|
Hello 👋, and thank you for the fantastic library. It has really helped my team simplify how we work with server cache! I have a question. In the README example, we can see the following snippet: function Todo({ todoId, preview }) {
const { status, data, error } = useQuery(
// These will be used as the query key
['todo', todoId],
// These will get passed directly to our query function
[
debug,
{
foo: true,
bar: false,
},
],
fetchTodoById
)
}now if we were to write it as follows const { status, data, error } = useQuery({
queryFn: fetchTodoById,
queryKey: ['todo', todoId],
config: {
staleTime: Infinity,
},
});where should the optional variables be included? |
Answered by
dimitrisnl
Jun 3, 2020
Replies: 2 comments
|
The so we rule it out. |
0 replies
|
It is my understanding that the useQuery({
queryKey: ['todo', 7],
queryFn: fetchTodos,
variables: [],
config: {},
}) |
0 replies
Answer selected by
dimitrisnl
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is my understanding that the
variableskey refers to the variables that dont affect the key, so this is the right place to add anything that shouldn't affect the caching mechanism.