amazon web services – With AWS AppSync GraphQL Allowing Users to be Friends

Even tho I’ve tried a few ways, I couldn’t create a complete schema which allows users to:

  • search each other with their usernames
  • send and receive friend requests
  • become friends with each other if one accepted the other’s request

How can I implement these functionalities to my app using AWS AppSync GraphQL API?

Here is the pretty simplified version of my approach.

type User @model {
  id: ID!
  username: String!
  friendRequests: [FriendRequest] @hasMany
  friends: [User] @hasMany
}

type FriendRequest @model {
  id: ID!
  sender: User! @belongsTo
  receiver: User! @belongsTo
  status: String!
}

Read more here: Source link