Testing phaseThis environment is in pre-launch testing — all data will be reset at launch.
Skip to content

API Design ​

The API design area controls how your domain model is exposed as a GraphQL API. Not every entity or operation needs to be public. This is where you shape the consumer-facing API contract — deciding which queries exist, what they are called, and how they behave by default.

API design sits between modelling and runtime. The Modelling Board and Tables & Attributes define what your domain looks like structurally. API design determines what consumers can actually reach.

Overview ​

When you open the API design view, you see a list of all tables in your current project. Each table row exposes configuration controls for:

  • Query naming — the GraphQL query names consumers use to fetch data
  • Operation exposure — which query types (list, detail) are enabled
  • Pagination defaults — default page size, sort field, and sort direction

Changes take effect immediately: the mock API and the Preview & Hints view use the new configuration at once.

Screenshot ws-api-01-overviewScreenshot ws-api-01-overview
ws-api-01-overviewMissing

API design view showing per-entity query configuration.

Query Naming ​

Mockomat generates query names automatically from your entity names. The default convention follows standard GraphQL practice:

  • List query — plural form of the entity name (e.g., products, customers, orderItems)
  • Detail query — singular form of the entity name (e.g., product, customer, orderItem)

Both names are fully customizable. You can override the defaults to match your frontend team's conventions or your organization's naming standards.

Why Naming Matters ​

Query names are part of the API contract. They appear in every GraphQL request your consumers write:

graphql
query {
  products(pageSize: 20) {
    items {
      id
      name
      price
    }
  }
}

If you rename products to catalogItems after consumers have integrated, every query that references products will break. Choose names deliberately, and treat them as stable identifiers rather than labels.

Naming Guidelines ​

GuidelineExampleRationale
Use camelCaseorderItems, not order_itemsMatches GraphQL conventions
Be specificactiveProducts, not itemsReduces ambiguity across entities
Match domain languageinvoices, not billingRecordsAligns with how your team talks about the data
Keep singular/plural consistentproduct / productsConsumers expect this symmetry
Screenshot ws-api-02-query-namingScreenshot ws-api-02-query-naming
ws-api-02-query-namingMissing

Query name configuration for list and detail operations.

Operation Exposure ​

Each entity gets a list and a detail query by default. You control whether each operation is enabled or disabled independently:

OperationPurposeDefault
List queryFetch a paginated collection of recordsEnabled
Detail queryFetch a single record by identifierEnabled

Enabling and Disabling Operations ​

Toggle operations on or off per entity. The effect is immediate:

  • Enabled operations can be called by consumers under their name.
  • Disabled operations answer every call with an error saying the operation is disabled.

An entity with all operations disabled is still part of your data model: its mappings and relations remain intact. Disabling operations only removes direct query access.

When to Disable Operations ​

  • Internal entities that exist only to support relations (e.g., a join table for m:n relations) often do not need their own queries.
  • Draft entities that are not yet ready for consumer use can be disabled temporarily.
  • Restricted entities that should only be accessible through a parent entity's nested query (e.g., OrderItem accessed only via Order.items).
Screenshot ws-api-03-operation-togglesScreenshot ws-api-03-operation-toggles
ws-api-03-operation-togglesMissing

Operation toggles for enabling and disabling list and detail queries.

Pagination Defaults ​

Every list query supports page-based pagination (page, pageSize). The API design view lets you configure the defaults per operation:

SettingDescriptionTypical Range
Default page sizeRecords per page when the consumer sends no pageSize10 -- 50
Default sort fieldThe attribute used for ordering when no sort is specifiedAny attribute bound to a data column
Default sort directionASC or DESCDepends on the sort field

Consumers can override the page size and sort in their queries. The page size is capped at 100 for every operation: a request for pageSize: 1000 returns at most 100 records.

Choosing Defaults ​

Pagination defaults shape the initial consumer experience. Consider:

  • High-traffic entities (e.g., products in a catalog) benefit from a smaller default page size (10--20) to keep responses fast.
  • Reference entities (e.g., countries, currencies) with small datasets can use a higher default page size (50--100) since consumers often need the full list.
  • Sort field should reflect the most natural ordering. For time-series data, sort by createdAt DESC. For alphabetical listings, sort by name ASC.
Screenshot ws-api-04-pagination-defaultsScreenshot ws-api-04-pagination-defaults
ws-api-04-pagination-defaultsMissing

Pagination default configuration per entity.

GraphQL Schema Generation ​

Mockomat generates a GraphQL schema automatically from your model and API design configuration. The schema generation process follows a direct mapping:

API Design SettingSchema Effect
Enabled list queryAdds a collection query to the schema root
Enabled detail queryAdds a single-record query to the schema root
Query nameBecomes the exact query field name
Attribute typesMap to GraphQL scalar types (String, Int, Float, Boolean)
RelationsGenerate nested object types in the schema
Pagination settingsDefine default argument values

The schema is regenerated every time you change an API design setting. You do not need to trigger a build or deploy step — the Runtime serves the updated schema immediately.

GraphQL vs REST ​

Mockomat generates GraphQL APIs by default. The mock runtime serves GraphQL at:

text
POST /mock/{slug}/graphql

REST-style operations are available through the Export feature, which generates full backend code from your model. The API design view focuses exclusively on GraphQL operation configuration.

Design Principles ​

API design decisions compound over time. A well-designed API surface reduces integration friction and support burden. The following principles help you make decisions that remain stable as your model evolves.

Start Narrow ​

Expose fewer operations initially. It is always easier to add a new query than to remove one that consumers already depend on. Begin with the minimum set of queries your frontend needs, and expand coverage as the model stabilizes.

Name Intentionally ​

Query names are contracts, not labels. Before committing to a name, ask:

  • Would a developer unfamiliar with this project understand what this query returns?
  • Does this name conflict with any other query in the schema?
  • Is this name stable enough to survive the next iteration of the model?

Validate Before Exposing ​

Use the Preview & Hints view to confirm that each enabled operation behaves correctly before sharing the endpoint with consumers. Check that:

  • The response structure matches expectations
  • Pagination defaults produce reasonable page sizes
  • Sort order is intuitive for the data type
  • No unresolved hints remain for the entity

Think Like a Consumer ​

Step outside the modeller's perspective. Consider:

  • What queries would a frontend developer write to build a listing page?
  • What queries would they need for a detail view?
  • Would they need to filter by a field that has no parameter yet, or sort by a field that is not bound to data yet?

This perspective check often reveals missing configuration before consumers encounter it.

Causality: API Design to Consumer Experience ​

Every setting in the API design view has a direct, traceable effect on the consumer experience. Understanding this causality helps you predict the impact of changes before making them.

API Design ActionDownstream Effect
Enable a list queryConsumers can fetch paginated collections of that entity
Disable a list queryCalls to it answer an error; existing consumer queries fail
Change a query nameAll consumers must update their queries to use the new name
Change the default page sizeConsumers who send no pageSize receive a different number of records (at most 100)
Change default sort fieldThe default ordering of results changes for consumers who do not specify a sort
Add a parameterConsumers can filter by it; unknown arguments are answered with BAD_USER_INPUT

Every API design change applies immediately: the Runtime and the Preview & Hints view use the new configuration at once.

Screenshot ws-api-05-causality-flowScreenshot ws-api-05-causality-flow
ws-api-05-causality-flowMissing

Causality diagram: API design settings flow to schema and consumer experience.

Workflow Integration ​

API design is not a standalone step. It connects to every other workspace area:

  1. Model your domain on the Modelling Board — create tables, define attributes, establish relations.
  2. Configure attributes in Tables & Attributes — set types, the Searchable flag, and data mappings.
  3. Design your API surface here — name queries, toggle operations, set pagination defaults.
  4. Validate behavior in Preview & Hints — run queries, review hints, confirm correctness.
  5. Test with real queries in the Runtime — execute the same queries consumers will use.
  6. Export when ready via Export — generate backend code from your validated model.

Changes in earlier stages propagate forward. Adding a new attribute in the table editor automatically makes it available in the schema. Removing a relation updates the schema to reflect the change. The API design view gives you control over what is exposed, but the underlying structure comes from the model.

Screenshot ws-api-06-workflow-integrationScreenshot ws-api-06-workflow-integration
ws-api-06-workflow-integrationMissing

API design in the context of the full workspace workflow.