-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathuseLoadFeatureViewsREST.ts
More file actions
41 lines (37 loc) · 972 Bytes
/
Copy pathuseLoadFeatureViewsREST.ts
File metadata and controls
41 lines (37 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { useQuery } from "react-query";
import { fetchApi } from "./restApi";
interface FeatureViewListResponse {
featureViews: any[];
pagination: Record<string, any>;
relationships?: Record<string, any[]>;
}
const useLoadFeatureViewsREST = (project: string) => {
return useQuery(
["feature-views-rest", project],
() =>
fetchApi<FeatureViewListResponse>("/feature_views", {
project,
allow_cache: "false",
}),
{
enabled: !!project,
staleTime: 30000,
},
);
};
const useLoadFeatureViewREST = (name: string, project: string) => {
return useQuery(
["feature-view-rest", name, project],
() =>
fetchApi<any>(`/feature_views/${encodeURIComponent(name)}`, {
project,
include_relationships: "true",
allow_cache: "false",
}),
{
enabled: !!name && !!project,
staleTime: 30000,
},
);
};
export { useLoadFeatureViewsREST, useLoadFeatureViewREST };