@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.
- package/cache/config.ts +56 -0
- package/cache/index.ts +861 -0
- package/cache/utils.ts +56 -0
- package/gql/fragments/authFragments.ts +8 -0
- package/gql/fragments/billingFragments.ts +25 -0
- package/gql/fragments/cardFragments.ts +15 -0
- package/gql/fragments/chatFragments.ts +98 -0
- package/gql/fragments/otherFragments.ts +21 -0
- package/gql/fragments/userFragments.ts +69 -0
- package/gql/mutations/authMutations.ts +197 -0
- package/gql/mutations/billingMutations.ts +34 -0
- package/gql/mutations/chatMutations.ts +116 -0
- package/gql/mutations/otherMutations.ts +46 -0
- package/gql/mutations/userMutations.ts +89 -0
- package/gql/queries/authQueries.ts +13 -0
- package/gql/queries/billingQueries.ts +12 -0
- package/gql/queries/cardQueries.ts +24 -0
- package/gql/queries/chatQueries.ts +86 -0
- package/gql/queries/otherQueries.ts +12 -0
- package/gql/queries/userQueries.ts +104 -0
- package/main.ts +2 -0
- package/package.json +38 -0
- package/types.d.ts +31 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { friendFragment, userFragment, userPersonaFragment, plusFragment } from '../fragments/userFragments';
|
|
3
|
+
|
|
4
|
+
export const editUserMtn = gql`
|
|
5
|
+
mutation editUser (
|
|
6
|
+
$photoId: GenericID
|
|
7
|
+
$backgroundPhotoId: GenericID
|
|
8
|
+
$user: UserInput
|
|
9
|
+
$profile: UserProfileInput
|
|
10
|
+
$theme: ThemeInput
|
|
11
|
+
) {
|
|
12
|
+
editUser (
|
|
13
|
+
photoId: $photoId
|
|
14
|
+
backgroundPhotoId: $backgroundPhotoId
|
|
15
|
+
user: $user
|
|
16
|
+
profile: $profile
|
|
17
|
+
theme: $theme
|
|
18
|
+
) {
|
|
19
|
+
...userFragment
|
|
20
|
+
lightMode
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
${userFragment}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const editUserPlusMtn = gql`
|
|
28
|
+
mutation editUserPlus (
|
|
29
|
+
$badge: String
|
|
30
|
+
) {
|
|
31
|
+
editUserPlus (
|
|
32
|
+
badge: $badge
|
|
33
|
+
) {
|
|
34
|
+
...plusFragment
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
${plusFragment}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export const editUserFriendshipMtn = gql`
|
|
42
|
+
mutation editUserFriendship (
|
|
43
|
+
$userId: UserID!
|
|
44
|
+
$friendStatus: FriendStatus!
|
|
45
|
+
) {
|
|
46
|
+
editUserFriendship (
|
|
47
|
+
userId: $userId
|
|
48
|
+
friendStatus: $friendStatus
|
|
49
|
+
) {
|
|
50
|
+
...friendFragment
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
${friendFragment}
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const editPersonasMtn = gql`
|
|
58
|
+
mutation editPersonas (
|
|
59
|
+
$personas: [UserPersonaInput]
|
|
60
|
+
) {
|
|
61
|
+
editPersonas (
|
|
62
|
+
personas: $personas
|
|
63
|
+
) {
|
|
64
|
+
...userPersonaFragment
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
${userPersonaFragment}
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
export const addEditPersonaMtn = gql`
|
|
72
|
+
mutation addEditPersona (
|
|
73
|
+
$personaId: GenericID
|
|
74
|
+
$order: Int
|
|
75
|
+
$name: String
|
|
76
|
+
$photoId: GenericID
|
|
77
|
+
) {
|
|
78
|
+
addEditPersona(
|
|
79
|
+
personaId: $personaId
|
|
80
|
+
order: $order
|
|
81
|
+
name: $name
|
|
82
|
+
photoId: $photoId
|
|
83
|
+
) {
|
|
84
|
+
...userPersonaFragment
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
${userPersonaFragment}
|
|
89
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { platformProductFragment } from '../fragments/billingFragments';
|
|
3
|
+
|
|
4
|
+
export const platformProductsQry = gql`
|
|
5
|
+
query platformProducts {
|
|
6
|
+
platformProducts {
|
|
7
|
+
...platformProductFragment
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
${platformProductFragment}
|
|
12
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { cardFragment, linkFragment } from '../fragments/cardFragments';
|
|
3
|
+
|
|
4
|
+
export const cardsForUserQry = gql`
|
|
5
|
+
query cardsForUser (
|
|
6
|
+
$userId: UserID!
|
|
7
|
+
) {
|
|
8
|
+
cardsForUser (
|
|
9
|
+
userId: $userId
|
|
10
|
+
) {
|
|
11
|
+
id
|
|
12
|
+
cards {
|
|
13
|
+
...cardFragment
|
|
14
|
+
|
|
15
|
+
links {
|
|
16
|
+
...linkFragment
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
${cardFragment}
|
|
23
|
+
${linkFragment}
|
|
24
|
+
`;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { chatFragment, chatMessageFragment, chatPartial, chatUserStatusFragment } from '../fragments/chatFragments';
|
|
3
|
+
import { userPartial } from '../fragments/userFragments';
|
|
4
|
+
|
|
5
|
+
export const chatsListQry = gql`
|
|
6
|
+
query chatsList (
|
|
7
|
+
$cursor: Cursor
|
|
8
|
+
$after: Boolean!
|
|
9
|
+
$limit: Int!
|
|
10
|
+
) {
|
|
11
|
+
chatsList (
|
|
12
|
+
cursor: $cursor
|
|
13
|
+
after: $after
|
|
14
|
+
limit: $limit
|
|
15
|
+
) {
|
|
16
|
+
cursor
|
|
17
|
+
...chatFragment
|
|
18
|
+
|
|
19
|
+
userStatus {
|
|
20
|
+
...chatUserStatusFragment
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${chatFragment}
|
|
26
|
+
${chatUserStatusFragment}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const myChatsQry = gql`
|
|
30
|
+
query myChats (
|
|
31
|
+
$type: ChatType!
|
|
32
|
+
) {
|
|
33
|
+
myChats (
|
|
34
|
+
type: $type
|
|
35
|
+
) {
|
|
36
|
+
...chatPartial
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
${chatPartial}
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
export const chatQry = gql`
|
|
44
|
+
query chat (
|
|
45
|
+
$chatId: GenericID!
|
|
46
|
+
$cursor: Cursor
|
|
47
|
+
$after: Boolean!
|
|
48
|
+
$limit: Int!
|
|
49
|
+
) {
|
|
50
|
+
chat (
|
|
51
|
+
chatId: $chatId
|
|
52
|
+
) {
|
|
53
|
+
...chatPartial
|
|
54
|
+
|
|
55
|
+
participants {
|
|
56
|
+
...userPartial
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
messages (
|
|
60
|
+
cursor: $cursor
|
|
61
|
+
after: $after
|
|
62
|
+
limit: $limit
|
|
63
|
+
) {
|
|
64
|
+
cursor
|
|
65
|
+
...chatMessageFragment
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
${chatPartial}
|
|
71
|
+
${chatMessageFragment}
|
|
72
|
+
${userPartial}
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
export const userIdToChatIdQry = gql`
|
|
76
|
+
query userIdToChatId (
|
|
77
|
+
$userId: UserID!
|
|
78
|
+
) {
|
|
79
|
+
userIdToChatId (
|
|
80
|
+
userId: $userId
|
|
81
|
+
) {
|
|
82
|
+
id
|
|
83
|
+
friendId
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { gql } from 'graphql-tag';
|
|
2
|
+
import { friendFragment, userFragment } from '../fragments/userFragments';
|
|
3
|
+
|
|
4
|
+
export const searchUsersQry = gql`
|
|
5
|
+
query searchUsers (
|
|
6
|
+
$searchQuery: String!
|
|
7
|
+
) {
|
|
8
|
+
searchUsers (
|
|
9
|
+
searchQuery: $searchQuery
|
|
10
|
+
) {
|
|
11
|
+
query
|
|
12
|
+
results {
|
|
13
|
+
...friendFragment
|
|
14
|
+
|
|
15
|
+
user {
|
|
16
|
+
...userFragment
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
${friendFragment}
|
|
23
|
+
${userFragment}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const friendQry = gql`
|
|
27
|
+
query friend (
|
|
28
|
+
$userId: UserID!
|
|
29
|
+
) {
|
|
30
|
+
friend (
|
|
31
|
+
userId: $userId
|
|
32
|
+
) {
|
|
33
|
+
...friendFragment
|
|
34
|
+
|
|
35
|
+
user {
|
|
36
|
+
...userFragment
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${friendFragment}
|
|
42
|
+
${userFragment}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const friendsListQry = gql`
|
|
46
|
+
query friendsList (
|
|
47
|
+
$cursor: Cursor
|
|
48
|
+
$after: Boolean!
|
|
49
|
+
$limit: Int!
|
|
50
|
+
) {
|
|
51
|
+
friendsList (
|
|
52
|
+
cursor: $cursor
|
|
53
|
+
after: $after
|
|
54
|
+
limit: $limit
|
|
55
|
+
) {
|
|
56
|
+
cursor
|
|
57
|
+
...friendFragment
|
|
58
|
+
|
|
59
|
+
user {
|
|
60
|
+
...userFragment
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
${friendFragment}
|
|
66
|
+
${userFragment}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export const friendRequestsQry = gql`
|
|
70
|
+
query friendRequests (
|
|
71
|
+
$pendingOnly: Boolean
|
|
72
|
+
) {
|
|
73
|
+
friendRequests (
|
|
74
|
+
pendingOnly: $pendingOnly
|
|
75
|
+
) {
|
|
76
|
+
...friendFragment
|
|
77
|
+
|
|
78
|
+
user {
|
|
79
|
+
...userFragment
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
${friendFragment}
|
|
85
|
+
${userFragment}
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
// Unused at the moment
|
|
89
|
+
// export const personasQry = gql`
|
|
90
|
+
// query personas (
|
|
91
|
+
// $userId: UserID
|
|
92
|
+
// ) {
|
|
93
|
+
// personas (
|
|
94
|
+
// userId: $userId
|
|
95
|
+
// ) {
|
|
96
|
+
// id
|
|
97
|
+
// list {
|
|
98
|
+
// ...userPersonaFragment
|
|
99
|
+
// }
|
|
100
|
+
// }
|
|
101
|
+
// }
|
|
102
|
+
|
|
103
|
+
// ${userPersonaFragment}
|
|
104
|
+
// `;
|
package/main.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jsb188/graphql",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "GraphQL client for react, using recoil",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "jsb188",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "main.ts",
|
|
9
|
+
"types": "types.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./main.ts",
|
|
12
|
+
"./fragments/auth": "./gql/fragments/authFragments.ts",
|
|
13
|
+
"./fragments/billing": "./gql/fragments/billingFragments.ts",
|
|
14
|
+
"./fragments/card": "./gql/fragments/cardFragments.ts",
|
|
15
|
+
"./fragments/chat": "./gql/fragments/chatFragments.ts",
|
|
16
|
+
"./fragments/other": "./gql/fragments/otherFragments.ts",
|
|
17
|
+
"./fragments/user": "./gql/fragments/userFragments.ts",
|
|
18
|
+
"./mutations/auth": "./gql/mutations/authMutations.ts",
|
|
19
|
+
"./mutations/billing": "./gql/mutations/billingMutations.ts",
|
|
20
|
+
"./mutations/chat": "./gql/mutations/chatMutations.ts",
|
|
21
|
+
"./mutations/other": "./gql/mutations/otherMutations.ts",
|
|
22
|
+
"./mutations/user": "./gql/mutations/userMutations.ts",
|
|
23
|
+
"./queries/auth": "./gql/queries/authQueries.ts",
|
|
24
|
+
"./queries/billing": "./gql/queries/billingQueries.ts",
|
|
25
|
+
"./queries/card": "./gql/queries/cardQueries.ts",
|
|
26
|
+
"./queries/chat": "./gql/queries/chatQueries.ts",
|
|
27
|
+
"./queries/other": "./gql/queries/otherQueries.ts",
|
|
28
|
+
"./queries/user": "./gql/queries/userQueries.ts",
|
|
29
|
+
"./types": "./types.d.ts",
|
|
30
|
+
"./utils": "./cache/utils.ts"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"graphql-tag": "^2.12.6"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
export interface ServerErrorObj {
|
|
3
|
+
statusCode: number;
|
|
4
|
+
errorCode: string;
|
|
5
|
+
errorValue?: string;
|
|
6
|
+
iconName?: string;
|
|
7
|
+
title: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SimpleErrorType {
|
|
12
|
+
iconName?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface APIRequestOutput {
|
|
18
|
+
aborted?: boolean;
|
|
19
|
+
error: ServerErrorObj | null;
|
|
20
|
+
[apiName: string]: any; // Different name & data; it depends on API
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface GraphQLHandlers {
|
|
24
|
+
resetErrors: () => void;
|
|
25
|
+
setError: (error: SimpleErrorType) => void;
|
|
26
|
+
refetch: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type UpdateObserversFn = (args: UpdateDataObserverArgs) => void;
|
|
30
|
+
export type OnCompletedGQLFn = (data: any, error: ServerErrorObj | null, variables: any) => void;
|
|
31
|
+
export type OnErrorGQLFn = (error: ServerErrorObj | null, variables: any) => void;
|