Skip to content

1. List the authors

Put the library’s authors on screen with DataTableForObservableQuery and the generated AllAuthors query. This query is observable: it can deliver updated results after the first load, and the table renders those results without application subscription code.

Before creating the component, complete the tutorial prerequisites. You need the running Arc library backend, generated src/Authors/Author.ts, and the providers and CSS from Getting started. An empty result is fine; the next chapter adds an author.

  1. Render the table. DataTableForObservableQuery takes the query proxy, subscribes to it, and renders each result as a row. You describe the columns with the Cratis-owned Column marker. Its field string must match a property on the generated Author read model, the row shape returned by the query:

    src/Authors.tsx
    import { Page } from '@cratis/components/Common';
    import { Column, DataTableForObservableQuery } from '@cratis/components/DataTables';
    import { AllAuthors } from './Authors/Author'; // generated observable query proxy
    export const Authors = () => (
    <Page title='Authors' showTitle>
    <DataTableForObservableQuery query={AllAuthors} emptyMessage='No authors yet'>
    <Column field='name' header='Name' sortable />
    </DataTableForObservableQuery>
    </Page>
    );
  2. Put it on screen. Render <Authors /> inside the providers from Getting started — in the Arc tutorial’s src/App.tsx, that means replacing its plain list with this component. Run the frontend and open the page. You see a table with a Name column: Loading… until the first result arrives, then one row per author you registered in the Arc tutorial, or No authors yet if there are none. A failed query shows Could not load data. instead of the empty message; an unauthorized query shows You are not authorized to view this data.

Page is the layout root for a routable view: a column that fills its parent. Here showTitle renders Authors as a level-one heading. Without it, title alone is not visible; neither prop sets the browser tab title.

What you see What it means What to do
Loading… with no rows The first result is pending If it persists, inspect the query request and backend connection
No authors yet A successful query returned no authors Continue to the add-author chapter
Author names A successful result supplied rows Compare them with your library data
Could not load data. The query failed Inspect the failed request and backend error, not the empty-state text
You are not authorized to view this data. The query is unauthorized Check application authentication and backend authorization

For connection failures, use Commands or queries do not reach the backend. An unstyled table is a separate CSS setup problem, not evidence that the query failed.

DataTableForObservableQuery uses Arc’s observable-query runtime to receive rows and query status, so this component needs no application fetch, useEffect, or subscription. When the query delivers a changed result, the table re-renders. Registering an author is a separate operation; in the next chapter you will check command completion first, then watch for the new row.

The generated query and its row values are typed, but Column.field is currently a plain string and the compiler does not validate it against the read model. Keep field names aligned with the generated row type and update them when the backend property changes. For custom cells, use Column<Author> with a typed body callback so row-property access is compiler-checked. A misspelled raw field value is a runtime display/configuration error rather than a TypeScript error.

You have an author table bound to AllAuthors, with a visible heading and separate loading, empty, failure, and unauthorized states. The table receives subsequent query results without subscription or fetch code in your component.

Once the table shows a successful result, including an empty one, add the author dialog →. Keep src/Authors.tsx; the next chapter adds an action to open the dialog from this screen.