@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.
@@ -4,6 +4,7 @@ fragment MessengerUser on UserAccount{
4
4
  familyName
5
5
  email
6
6
  username
7
+ fullName @client
7
8
  picture
8
9
  alias
9
10
  tokens {
@@ -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
  }
@@ -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';
@@ -1,3 +1,5 @@
1
1
  export * from './posts-policies';
2
2
  export * from './user-policies';
3
3
  export * from './channel-policies';
4
+ export * from './user-account-policies'
5
+ export * from './messages-policies'
@@ -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! = 30, $skip: Int! = 0) {
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
  }
@@ -1,4 +1,6 @@
1
1
  import postSchema from './post.graphql';
2
+ import userAccountSchema from './user-account.graphql'
3
+ import messagesSchema from './messages.graphql'
2
4
 
3
- const schema = [postSchema];
5
+ const schema = [postSchema,userAccountSchema,messagesSchema];
4
6
  export { schema };
@@ -0,0 +1,3 @@
1
+ extend type Messages {
2
+ messagesRefId: String
3
+ }
@@ -0,0 +1,3 @@
1
+ extend type UserAccount {
2
+ fullName: String
3
+ }