Week 14: Creating Records through Relationships/Associations

If you are most familiar with REST APIs, you’re probably used to creating/updating/deleting records using different endpoints (i.e., POST /article, PUT /article/slug, DELETE /article/slug). There’s nothing wrong with that! 8base’s GraphQL operations open up some pretty cool abilities though that you may not have expected to work as they do.

Did you know you can create two records in two separate tables using one GraphQL operation? Meanwhile, the relationship between them gets set up exactly as is defined in your data model.

Creating Records through Relationships-Associations1

We’re not only creating a new campaign record using the campaignCreate operation in the mutation above, but also an invoice record. Since the invoice is being created through the campaign relationship, the association of these two new records will be handled automatically. Boom 💥

Creating Records through Relationships-Associations2

Check out the Related Record Mutations in our docs to learn more. If you have any questions about this, definitely ask them in the 8base Community (https://community.8base.com)!

Happy Developing!