@jsb188/graphql 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+
2
+ /**
3
+ * Rules for GraphQL server that's hard-coded to this package
4
+ * NOTE: Allow config setup for this later
5
+ */
6
+
7
+ export const QUERY_EXPIRE_TIMES = {
8
+ __default: 3.6e+6, // 1 hour
9
+ // 6.48e+7, // 18 hours
10
+ } as {
11
+ [key: string]: number;
12
+ };
13
+
14
+ export const RULES = {
15
+ // __limit: 8000, // 8000: approximately 5.15 MB; calculated at 644.666666668 bytes for 30 objects
16
+ __limit: 100000, // 12000: approximately 7.725 MB; calculated at 644.666666668 bytes for 30 objects
17
+ // __limit: 50, // 12000: approximately 7.725 MB; calculated at 644.666666668 bytes for 30 objects
18
+
19
+ // List of queries that should be cached
20
+ // NOTE: Fragments are always cached
21
+ alerts: true,
22
+ cardsForUser: true,
23
+ chat: true,
24
+ chatsList: true,
25
+ editChat: true,
26
+ friend: true,
27
+ friendsList: true,
28
+ friendRequests: true,
29
+ myChats: true,
30
+ platformProducts: true,
31
+ searchUsers: true,
32
+ updateNote: true,
33
+ userIdToChatId: true,
34
+
35
+ // All fragments are cached,
36
+ // but if you want to skip some, add it here
37
+ authFragment: false,
38
+ } as {
39
+ __limit: number;
40
+ [key: string]: boolean | number;
41
+ };
42
+
43
+ export const PARTIALS_MAP = {
44
+ // Partial fragments are supported if you map them to its original fragment name
45
+ chatPartial: 'chatFragment',
46
+ chatStatusPartial: 'chatFragment',
47
+ userPartial: 'userFragment',
48
+ };
49
+
50
+ /**
51
+ * Set up config, so the package can use app's variables
52
+ */
53
+
54
+ export function configGraphQL(_rules: any) {
55
+ // Do something with rules and partials map here
56
+ }