WHAT YOU'LL LEARN
  • What is a private model and how does it differ from public models?
  • How to create a private model using the Model Builder?
  • When to use private models?

Overview
anchor

This example demonstrates how to create a private model and why would you use it or need it.

Private models are not exposed through the GraphQL API, so you need to expose them yourself if required (build a schema and resolvers).

Private Model Builder
anchor

Usage of the Defined Private Model
anchor

For example, you want to log every time user authenticates in your application.

What's Happening Here
anchor

This example demonstrates a practical use case for private models. The LogUser handler intercepts authentication events and stores user login data in the private userLog model.

Since the model is private, this data is only accessible through your backend code, not through the public GraphQL API. This is perfect for internal logging, analytics, or storing sensitive data that shouldn’t be exposed to frontend applications.

Accessing Private Model Data
anchor

To access data from a private model, you would typically create custom GraphQL resolvers or use the CMS API directly in your backend code.

This allows you to control who can access this data and how it’s used, ensuring that sensitive information remains secure.