Skip to content

Commit

Permalink
add conversations query
Browse files Browse the repository at this point in the history
  • Loading branch information
gondar00 committed Mar 16, 2020
1 parent 6b5873c commit cffd0f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"scripts": {
"start": "nodemon src/index.js",
"playground": "graphql playground"
"playground": "graphql playground --port 4001"
},
"dependencies": {
"graphql-yoga": "^1.16.2",
Expand Down
4 changes: 2 additions & 2 deletions src/resolvers/Mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ const Mutation = {
}
}

return await context.prisma.mutation.createConversation({ data }, info)
return context.prisma.mutation.createConversation({ data }, info)
},
async sendTextMessage ({ userId }, { conversationId, text }, context, info) {
return await context.prisma.mutation.createText(
return context.prisma.mutation.createText(
{
data: {
text,
Expand Down
7 changes: 5 additions & 2 deletions src/resolvers/Query.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const Query = {
async users ({ userId }, args, context, info) {
return await context.prisma.query.users(
return context.prisma.query.users(
{ where: { id_not: userId } },
info
)
},
async me ({ userId }, args, context, info) {
return await context.prisma.query.user({ where: { id: userId } }, info)
return context.prisma.query.user({ where: { id: userId } }, info)
},
async conversations (NULL, args, context, info) {
return context.prisma.query.conversations(null, info)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
type Query {
users: [User!]!
me: User
conversations: [Conversation]
}

type Mutation {
Expand Down

0 comments on commit cffd0f1

Please sign in to comment.