@messenger-box/platform-client 0.0.1-alpha.390 → 0.0.1-alpha.391
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/CHANGELOG.md +4 -0
- package/lib/generated-model.d.ts +11 -4
- package/lib/graphql/index.d.ts +1 -1
- package/lib/graphql/policies/index.d.ts +2 -0
- package/lib/graphql/policies/messages-policies.d.ts +2 -0
- package/lib/graphql/policies/user-account-policies.d.ts +2 -0
- package/lib/index.js +120 -23
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/generated-model.tsx +33 -26
- package/src/graphql/fragments/messenger-user.gql +1 -0
- package/src/graphql/fragments/post-message.gql +5 -1
- package/src/graphql/index.ts +2 -2
- package/src/graphql/policies/index.ts +2 -0
- package/src/graphql/policies/messages-policies.ts +28 -0
- package/src/graphql/policies/user-account-policies.ts +15 -0
- package/src/graphql/queries/messages.gql +2 -1
- package/src/graphql/schema/index.ts +3 -1
- package/src/graphql/schema/messages.graphql +3 -0
- package/src/graphql/schema/user-account.graphql +3 -0
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
fragment Post on Post {
|
|
2
|
+
id
|
|
3
|
+
channel {
|
|
4
|
+
id
|
|
5
|
+
}
|
|
2
6
|
author {
|
|
3
7
|
...MessengerUser
|
|
4
8
|
}
|
|
5
|
-
id
|
|
6
9
|
isPinned
|
|
7
10
|
message
|
|
8
11
|
type
|
|
@@ -12,6 +15,7 @@ fragment Post on Post {
|
|
|
12
15
|
createdAt
|
|
13
16
|
fromServer
|
|
14
17
|
updatedAt
|
|
18
|
+
|
|
15
19
|
propsConfiguration {
|
|
16
20
|
...Configuration
|
|
17
21
|
}
|
package/src/graphql/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { merge } from 'lodash';
|
|
2
|
-
import { postPolicies, userPolicies, channelPolicies } from './policies';
|
|
2
|
+
import { postPolicies, userPolicies, channelPolicies,userAccountPolicies,messagesPolicies } from './policies';
|
|
3
3
|
import { schema } from './schema';
|
|
4
4
|
|
|
5
|
-
const typePolicies = merge({}, postPolicies, userPolicies, channelPolicies);
|
|
5
|
+
const typePolicies = merge({}, postPolicies, userPolicies, channelPolicies,userAccountPolicies,messagesPolicies);
|
|
6
6
|
export { schema, typePolicies };
|
|
7
7
|
export * from './id-generation';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TypePolicies } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const messagesPolicies: TypePolicies = {
|
|
4
|
+
Messages: {
|
|
5
|
+
keyFields: ['messagesRefId'],
|
|
6
|
+
fields: {
|
|
7
|
+
messagesRefId: {
|
|
8
|
+
read(existing, { variables }) {
|
|
9
|
+
const { channelId, parentId }: any = variables;
|
|
10
|
+
return `${channelId}-${parentId}`;
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
Query: {
|
|
16
|
+
fields: {
|
|
17
|
+
messages: {
|
|
18
|
+
// keyArgs: ['channelId', 'parentId', 'limit', 'skip'],
|
|
19
|
+
keyArgs: ['channelId', 'parentId'],
|
|
20
|
+
merge(existing, incoming, { args, mergeObjects }) {
|
|
21
|
+
console.log('incoming', JSON.stringify(incoming));
|
|
22
|
+
return mergeObjects(existing, incoming);
|
|
23
|
+
//return existing ? { ...existing, ...incoming } : incoming;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TypePolicies } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const userAccountPolicies: TypePolicies = {
|
|
4
|
+
UserAccount: {
|
|
5
|
+
fields: {
|
|
6
|
+
fullName: {
|
|
7
|
+
read(_, { readField, toReference, }) {
|
|
8
|
+
const givenName = readField('givenName');
|
|
9
|
+
const familyName = readField('familyName');
|
|
10
|
+
return `${givenName} ${familyName}`;
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
query Messages($channelId: ID,$parentId: String, $limit: Int! =
|
|
1
|
+
query Messages($channelId: ID,$parentId: String, $limit: Int! = 10, $skip: Int! = 0) {
|
|
2
2
|
messages(channelId: $channelId,parentId:$parentId, limit: $limit, skip: $skip) {
|
|
3
|
+
messagesRefId @client
|
|
3
4
|
data{
|
|
4
5
|
...Post
|
|
5
6
|
}
|