feat(core): add useQueryImmutable (#5299)

This commit is contained in:
Peng Xiao
2023-12-14 08:04:50 +00:00
parent b925731bf7
commit c66781970b
3 changed files with 28 additions and 26 deletions

View File

@@ -1,8 +1,8 @@
import { getIsOwnerQuery } from '@affine/graphql';
import { useQuery } from '@affine/workspace/affine/gql';
import { useQueryImmutable } from '@affine/workspace/affine/gql';
export function useIsWorkspaceOwner(workspaceId: string) {
const { data } = useQuery({
const { data } = useQueryImmutable({
query: getIsOwnerQuery,
variables: {
workspaceId,

View File

@@ -1,5 +1,5 @@
import { serverConfigQuery } from '@affine/graphql';
import { useQuery } from '@affine/workspace/affine/gql';
import { useQueryImmutable } from '@affine/workspace/affine/gql';
import type { BareFetcher, Middleware } from 'swr';
const wrappedFetcher = (fetcher: BareFetcher<any> | null, ...args: any[]) =>
@@ -10,13 +10,10 @@ const errorHandler: Middleware = useSWRNext => (key, fetcher, config) => {
};
export const useServerFlavor = () => {
const { data: config, error } = useQuery(
const { data: config, error } = useQueryImmutable(
{ query: serverConfigQuery },
{
use: [errorHandler],
revalidateOnFocus: false,
revalidateOnMount: false,
revalidateIfStale: false,
}
);