Attempted to invoke queryFn when set to skipToken. This is likely a configuration error
loader: ({ context, params }) => {
const [cookies] = context.cookies
return context.queryClient.ensureQueryData({
...getProjectQueryOpts({
projectId: cookies.projectId,
})
})
}
});
loader: ({ context, params }) => {
const [cookies] = context.cookies
return context.queryClient.ensureQueryData({
...getProjectQueryOpts({
projectId: cookies.projectId,
})
})
}
});
export const getProjectQueryOpts = (
variables: Variables,
init: RequestInit = {},
) => {
return queryOptions({
queryKey: [
"projects",
variables.projectId
],
queryFn: variables.projectId ? () => getProject(variables, init) : skipToken,
});
};
export const getProjectQueryOpts = (
variables: Variables,
init: RequestInit = {},
) => {
return queryOptions({
queryKey: [
"projects",
variables.projectId
],
queryFn: variables.projectId ? () => getProject(variables, init) : skipToken,
});
};
export const getProjectQueryOpts = (
variables: Variables,
init: RequestInit = {},
) => {
if (!variables.projectId) {
return {
queryKey: ["projects", null],
queryFn: () => Promise.resolve(null),
};
}
return queryOptions({
queryKey: [
"projects",
variables.projectId
],
queryFn: () => getProject(variables, init),
});
};
export const getProjectQueryOpts = (
variables: Variables,
init: RequestInit = {},
) => {
if (!variables.projectId) {
return {
queryKey: ["projects", null],
queryFn: () => Promise.resolve(null),
};
}
return queryOptions({
queryKey: [
"projects",
variables.projectId
],
queryFn: () => getProject(variables, init),
});
};
export const getProjectQueryOpts = (
variables: Variables,
init: RequestInit = {},
) => {
return queryOptions({
queryKey: [
"projects",
variables.projectId
],
queryFn: () => variables.projectId ? getProject(variables, init) : null,
});
};
export const getProjectQueryOpts = (
variables: Variables,
init: RequestInit = {},
) => {
return queryOptions({
queryKey: [
"projects",
variables.projectId
],
queryFn: () => variables.projectId ? getProject(variables, init) : null,
});
};
1 Reply
quickest-silver•12mo ago
enabled
only works on hooks, and skipToken
is "just" a type-safe implementation of enabled
. Imperative methods can just not be called if you don' thave the available data, so:
loader: ({ context, params }) => {
const [cookies] = context.cookies
+ if (!cookies.projectId) return null
return context.queryClient.ensureQueryData({
...getProjectQueryOpts({
projectId: cookies.projectId,
})
})
}
});
loader: ({ context, params }) => {
const [cookies] = context.cookies
+ if (!cookies.projectId) return null
return context.queryClient.ensureQueryData({
...getProjectQueryOpts({
projectId: cookies.projectId,
})
})
}
});