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
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!) {
  createTweetHeart(
    input: { tweetHeart: { userId: $userId, tweetId: $tweetId } }
  ) {
    tweet {
      heartCount
    }
  }
}

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.

Want to allow your users to cast votes?

Midtype helps builders launch and iterate on web apps at light speed. We provide a hosted backend with user login, payments, a database, and much more built in. We allow you to focus on your core product without reinventing the wheel.

Add Password Based Accounts to Your App

Now, in addition to signing in with Google, your users can create their own password based accounts for your app. To maximize conversion…

Midtype as a Firebase Alternative

Firebase is a great platform on which to build a web app. It provides authentication, a massively scalable NoSQL datastore with real-time…

6 Lessons from Highly Effective Onboarding Experiences

Effective onboarding experiences are a key driver for improving customer conversion and reducing churn. Let’s pick up some tips from the…