-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
59 lines (51 loc) · 1.53 KB
/
Copy pathindex.tsx
File metadata and controls
59 lines (51 loc) · 1.53 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { ApolloProvider, ApolloClient, ApolloLink, InMemoryCache } from "@apollo/client";
import type { ReactNode } from "react";
import fragmentMatcher from "../__gen__/fragmentMatcher.json";
import { authLink, sentryLink, uploadLink, errorLink } from "./links";
import { paginationMerge } from "./pagination";
const Provider: React.FC<{ children?: ReactNode }> = ({ children }) => {
const endpoint = window.REEARTH_CONFIG?.api
? `${window.REEARTH_CONFIG.api}/graphql`
: "/api/graphql";
const cache = new InMemoryCache({
possibleTypes: fragmentMatcher.possibleTypes,
typePolicies: {
LayerGroup: {
fields: {
layers: {
merge: false,
},
},
},
Query: {
fields: {
assets: {
keyArgs: ["teamId", "keyword", "sort", "pagination", ["first", "last"]],
merge: paginationMerge,
},
projects: {
keyArgs: ["teamId", "last", "before"],
merge: paginationMerge,
},
datasetSchemas: {
keyArgs: ["sceneId", "first", "after"],
merge: paginationMerge,
},
},
},
},
});
const client = new ApolloClient({
uri: endpoint,
link: ApolloLink.from([
errorLink(),
sentryLink(endpoint),
authLink(),
uploadLink(endpoint) as unknown as ApolloLink,
]),
cache,
connectToDevTools: import.meta.env.DEV,
});
return <ApolloProvider client={client}>{children}</ApolloProvider>;
};
export default Provider;