Eating Our Own Dog Food - Building Amplication's Blog with Amplication

Michael  Solati
Michael Solati
Jun 27, 2022
Eating Our Own Dog Food - Building Amplication's Blog with AmplicationEating Our Own Dog Food - Building Amplication's Blog with Amplication

When we decided to revamp Amplication’s blog website, it was obvious that we would “eat our own dog food”. That is, we would use our own Node.js backedend developement tool to develop the solution. After all, when you develop an amazing platform to automate backend development, you would be crazy not to use it on your own projects (actually, we prefer to say “eat our own gourmet cuisine” but maybe we’re biased). We even use Amplication's Node.js backend development platform to build new services in Amplication, but that’s for another post…

Using Amplication enabled us to understand better how consumers experience our product and we were able to perform a form of quality control by testing the product in a real use-case situation. For these reasons, eating your own dog food is a valuable doctrine that you should consider in your own organization whenever possible.

During the development of the new website, we encountered several problems, and in this article, we will discuss what we did to solve them. We think this is a good case study of how using your own product can help you understand its strengths and overcome its limitations.

Building the Amplication blog platform

We built the API server hosting our blog content with Amplication. Amplication made the development process simpler by providing the following:

  • A database: where we save the content of the blog posts and the data about the authors and tagging.
  • A GraphQL API: to be used by the blog client to fetch the data to be presented
  • An admin UI: to be used by us to create new content, add blogs, authors, and tags.

In addition, we built the site that you visit, the blog client, with Next.js using GraphQL to fetch data from the API server. The client we built is also open-source, so feel free to use it for your next blog project.

Instantly generate
production-ready backend
Never waste time on repetitive coding again.
Try Now

What was missing

  • Public endpoints for readers of the blog to get the articles without authentication.
  • Filtering by relation, allowing readers to filter blog posts by tag.

The immediate solution

Amplication generated quality code that allowed us to easily alter and customize the API server we were building. So we were able to implement custom code in a few places.

Link to commit 1 -

Add public access to posts

Link to commit 2 -

Filter posts by tags

Link to commit 3 -

Resolve public fields for posts

Once we had the custom code in place, we figured that these features would also be used by other developers and decided it would benefit everyone if we took the custom code we implemented and added it to the platform.

The new features

Tag Filtering

As of version 0.11.2 of Amplication, there wasn't a way to filter entities based on their relation to another entity. You can review the GitHub issue here. A blog site has a one-to-many relationship between posts and tags. Each post in the blog has many tags, and users will want to query all posts based on tags. However, the WhereInput filter was not able to filter posts based on their relation to tags. To get all posts belonging to a tag we would have had to call the /api/tags/{id} endpoint for each tag, instead of querying all posts using the /api/posts endpoint and filtering the results to only those belonging to a certain tag.

This problem was quickly resolved by implementing the "-to-many" relation filter from Prisma. You can check out the pull request here.

This enhancement allows filtering based on the some, every, and none options when filtering an entity based on a "-to-many." For example, we can now filter posts that have some number of tags, we can also search for every post that has a tag, and we can find all posts that have no (none) tags tied to them.

This feature landed in Amplication version 0.11.4. You can learn more about v0.11.4 here.

Public Endpoints

One of the most requested features of Amplication was the ability to create models without auth guards.

Out of the box, Amplication provides a role-based permission model that is baked into your application. Developers can authorize access to data models for all roles and also granularly to specific roles. However, this requires all requests to be authenticated, which doesn't work well for a public blog.

To resolve this, a new entity permission type named Public was added alongside All Roles and Granular. As expected, the Public option makes an endpoint open to the public to make requests against, no longer requiring authentication or any specific role to access an endpoint. Perfect for querying blog posts.

This feature landed in Amplication version 0.12.7. You can learn more about v0.12.7 here.

A big thanks to Amit Barletz, an engineer on the Amplication team, who developed the Tag Filtering and Public Endpoint features that enabled us to build our website.

We're excited for you to use Amplication to build your next Node.js app, just like we've used it to build the site you're reading this on now!

Check out our tutorial to build a full-stack application with Amplication and React. If you're interested in what new features we're working on, we keep our roadmap public for you to review as well.