Skip to content

Instantly share code, notes, and snippets.

@bartosz-maciaszek
Created May 14, 2019 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bartosz-maciaszek/ef24af28692ccb8ec07da5cd87849641 to your computer and use it in GitHub Desktop.
Save bartosz-maciaszek/ef24af28692ccb8ec07da5cd87849641 to your computer and use it in GitHub Desktop.
client level
type User {
id: ID!
...
displayName: String!
...
friends: [User!]
friendshipRequestsSent: [FriendshipRequestSent!]!
friendshipRequestsReceived: [FriendshipRequestReceived!]!
}
type FriendshipRequestSent {
id: ID!
to: User!
status: FriendshipRequestStatus!
...
}
type FriendshipRequestReceived {
id: ID!
from: User!
status: FriendshipRequestStatus!
...
}
enum FriendshipRequestStatus {
PENDING
ACCEPTED
REJECTED
}
export default {
Query: {
async me(root, args, context) {
return await context.prisma.user({id: context.request.user.id});
}
},
User: {
async friendshipRequestsSent(root, args, context) {
return await context.prisma.user({
id: root.id
}).friendshipRequestsSent({
where: {
status: "PENDING"
}
});
},
async friendshipRequestsReceived(root, args, context) {
return await context.prisma.user({
id: root.id
}).friendshipRequestsReceived({
where: {
status: "PENDING"
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment