@mereb/app-messaging 0.0.3 → 0.0.4

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/dist/gql.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const CONVERSATIONS: import("@apollo/client").DocumentNode;
2
+ export declare const MESSAGES: import("@apollo/client").DocumentNode;
3
+ export declare const SEND_MESSAGE: import("@apollo/client").DocumentNode;
package/dist/gql.js ADDED
@@ -0,0 +1,50 @@
1
+ import { gql } from '@apollo/client';
2
+ export const CONVERSATIONS = gql `
3
+ query Conversations {
4
+ conversations {
5
+ id
6
+ title
7
+ participantIds
8
+ unreadCount
9
+ updatedAt
10
+ lastMessage {
11
+ id
12
+ senderName
13
+ body
14
+ sentAt
15
+ conversationId
16
+ }
17
+ }
18
+ }
19
+ `;
20
+ export const MESSAGES = gql `
21
+ query ConversationMessages($conversationId: ID!, $after: String) {
22
+ messages(conversationId: $conversationId, after: $after, limit: 50) {
23
+ edges {
24
+ cursor
25
+ node {
26
+ id
27
+ conversationId
28
+ senderName
29
+ body
30
+ sentAt
31
+ }
32
+ }
33
+ pageInfo {
34
+ endCursor
35
+ hasNextPage
36
+ }
37
+ }
38
+ }
39
+ `;
40
+ export const SEND_MESSAGE = gql `
41
+ mutation SendMessage($conversationId: ID, $toUserId: ID, $body: String!) {
42
+ sendMessage(conversationId: $conversationId, toUserId: $toUserId, body: $body) {
43
+ id
44
+ conversationId
45
+ senderName
46
+ body
47
+ sentAt
48
+ }
49
+ }
50
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mereb/app-messaging",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Messaging experience primitives for Mereb applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,6 +20,11 @@
20
20
  "types": "./dist/native.d.ts",
21
21
  "import": "./dist/native.js",
22
22
  "default": "./dist/native.js"
23
+ },
24
+ "./gql": {
25
+ "types": "./dist/gql.d.ts",
26
+ "import": "./dist/gql.js",
27
+ "default": "./dist/gql.js"
23
28
  }
24
29
  },
25
30
  "files": [
@@ -30,10 +35,14 @@
30
35
  "peerDependencies": {
31
36
  "expo-router": ">=3.0.0",
32
37
  "react": ">=18.2.0",
33
- "react-native": ">=0.72.0"
38
+ "react-native": ">=0.72.0",
39
+ "@apollo/client": ">=3.0.0",
40
+ "graphql": ">=16.0.0"
34
41
  },
35
42
  "devDependencies": {
43
+ "@apollo/client": "^3.12.5",
36
44
  "@types/react": "~18.2.79",
45
+ "graphql": "^16.11.0",
37
46
  "typescript": ">=5.3.3"
38
47
  },
39
48
  "scripts": {
package/src/gql.ts ADDED
@@ -0,0 +1,53 @@
1
+ import {gql} from '@apollo/client'
2
+
3
+ export const CONVERSATIONS = gql`
4
+ query Conversations {
5
+ conversations {
6
+ id
7
+ title
8
+ participantIds
9
+ unreadCount
10
+ updatedAt
11
+ lastMessage {
12
+ id
13
+ senderName
14
+ body
15
+ sentAt
16
+ conversationId
17
+ }
18
+ }
19
+ }
20
+ `
21
+
22
+ export const MESSAGES = gql`
23
+ query ConversationMessages($conversationId: ID!, $after: String) {
24
+ messages(conversationId: $conversationId, after: $after, limit: 50) {
25
+ edges {
26
+ cursor
27
+ node {
28
+ id
29
+ conversationId
30
+ senderName
31
+ body
32
+ sentAt
33
+ }
34
+ }
35
+ pageInfo {
36
+ endCursor
37
+ hasNextPage
38
+ }
39
+ }
40
+ }
41
+ `
42
+
43
+ export const SEND_MESSAGE = gql`
44
+ mutation SendMessage($conversationId: ID, $toUserId: ID, $body: String!) {
45
+ sendMessage(conversationId: $conversationId, toUserId: $toUserId, body: $body) {
46
+ id
47
+ conversationId
48
+ senderName
49
+ body
50
+ sentAt
51
+ }
52
+ }
53
+ `