Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
Triz_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2020-06-01 05:20:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
375f45b58320b36059ec07c7d28a0c0b85b6111a
375f45b5
1 parent
dc70be39
add pubsub
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletions
back/src/api/Message/createMessage/createMessage.js
back/src/api/Message/createMessage/createMessage.js
View file @
375f45b
import
{
prisma
,
isAuthenticated
}
from
"../../../utils"
;
import
{
NEW_MESSAGE
}
from
"../../../topics"
;
export
default
{
Mutation
:
{
createMessage
:
async
(
_
,
args
,
{
request
})
=>
{
createMessage
:
async
(
_
,
args
,
{
request
,
pubsub
})
=>
{
isAuthenticated
(
request
);
const
{
user
}
=
request
;
const
{
message
,
roomId
}
=
args
;
...
...
@@ -46,6 +47,11 @@ export default {
}
else
{
throw
new
Error
(
"There is no room"
);
}
if
(
messageObj
!==
undefined
)
{
pubsub
.
publish
(
NEW_MESSAGE
,
{
subMessage
:
messageObj
});
}
return
messageObj
;
},
},
...
...
Please
register
or
login
to post a comment