@moneypot/hub 1.14.6 → 1.14.7
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { gql,
|
|
2
|
-
import { context, inhibitOnNull
|
|
3
|
-
export const HubCurrentXPlugin =
|
|
1
|
+
import { gql, extendSchema } from "postgraphile/utils";
|
|
2
|
+
import { access, context, inhibitOnNull } from "postgraphile/grafast";
|
|
3
|
+
export const HubCurrentXPlugin = extendSchema((build) => {
|
|
4
4
|
const userTable = build.input.pgRegistry.pgResources.hub_user;
|
|
5
5
|
const casinoTable = build.input.pgRegistry.pgResources.hub_casino;
|
|
6
6
|
const experienceTable = build.input.pgRegistry.pgResources.hub_experience;
|
|
@@ -19,42 +19,25 @@ export const HubCurrentXPlugin = makeExtendSchemaPlugin((build) => {
|
|
|
19
19
|
plans: {
|
|
20
20
|
hubCurrentUser() {
|
|
21
21
|
const $identity = context().get("identity");
|
|
22
|
-
const $userId =
|
|
23
|
-
if (identity?.kind === "user") {
|
|
24
|
-
return identity.session.user_id;
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
});
|
|
22
|
+
const $userId = access($identity, ["session", "user_id"]);
|
|
28
23
|
return userTable.get({ id: inhibitOnNull($userId) });
|
|
29
24
|
},
|
|
30
25
|
hubCurrentCasino() {
|
|
31
26
|
const $identity = context().get("identity");
|
|
32
|
-
const $casinoId =
|
|
33
|
-
if (identity?.kind === "user") {
|
|
34
|
-
return identity.session.casino_id;
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
});
|
|
27
|
+
const $casinoId = access($identity, ["session", "casino_id"]);
|
|
38
28
|
return casinoTable.get({ id: inhibitOnNull($casinoId) });
|
|
39
29
|
},
|
|
40
30
|
hubCurrentExperience() {
|
|
41
31
|
const $identity = context().get("identity");
|
|
42
|
-
const $experienceId =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
});
|
|
32
|
+
const $experienceId = access($identity, [
|
|
33
|
+
"session",
|
|
34
|
+
"experience_id",
|
|
35
|
+
]);
|
|
48
36
|
return experienceTable.get({ id: inhibitOnNull($experienceId) });
|
|
49
37
|
},
|
|
50
38
|
hubCurrentSession() {
|
|
51
39
|
const $identity = context().get("identity");
|
|
52
|
-
const $sessionId =
|
|
53
|
-
if (identity?.kind === "user") {
|
|
54
|
-
return identity.session.session_id;
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
});
|
|
40
|
+
const $sessionId = access($identity, ["session", "session_id"]);
|
|
58
41
|
return sessionTable.get({ id: inhibitOnNull($sessionId) });
|
|
59
42
|
},
|
|
60
43
|
},
|