As of March 1, 2020, Midtype will be shutting down its services. Learn more.

Add Voting to Your App in 2 Minutes

Would you like to add something akin to a Facebook “like” or a Reddit “upvote” to your app? Midtype now allows you to do that in about 2 minutes. 

Starting today, Midtype can generate an API that allows your registered users to cast a “vote.” Vote is a new field type available to you when designing your Midtype models. It produces an API that provides users the ability to “vote” on individual records of that model.

How to Use It

Let’s walk through this feature by designing the API for the MVP version of Twitter:

The "Tweet" model from the MVP version of Twitter.

The “tweet” model has 3 fields: author, update, and heart. The author field is of type User and associates each record of the tweet model with the user that authored it. The update field is type Text and stores the actual content. Lastly, heart field is of type Vote and allows registered app users to “heart” a given tweet.

When you deploy this model, Midtype generates an API for you with the following resolver: createTweetHeart(input: CreateTweetHeartInput!). The input requires two fields: userId and tweetId. This resolver allows each authenticated user to “vote” (in this case: heart) and tweet they have visibility to. Here is an example of an API call that lets a user heart a tweet:

mutation($userId: String!, $tweetId: String!) {
    input: { tweetHeart: { userId: $userId, tweetId: $tweetId } }
  ) {
    tweet {

Each tweet record also has two additional resolvers: heartCount and tweetHearts. The heartCount field provides the number of users who “hearted” this tweet. The tweetHearts query provides a way to enumerate all those users.