Skip to main content

Overview

@reelevant-tech/data-sdk covers DataHub and the Datagraph: Datasources and their configuration steps, Mutable Datasources, the Datagraph Schema, Datagraph Objects and Datagraph Object Families. The example below queries a Datagraph Object for one customer, then creates a Mutable Datasource and writes two rows into it.

Two entrypoints

Use the root entrypoint to validate a Datagraph Object’s SQL or a Datagraph Schema in a pull request, without credentials. Use the client to read and write the account.

Client

Key concepts

Configuration steps. A Datasource is configured through an ordered list of steps (configure_name, configure_sources, configure_fields, … validate). datasources.runSteps(id, steps) validates them in order, checks before each call that the step is the expected one, and stops before validate if you pass stopAt: 'validate'. Mutable Datasources. A Mutable Datasource is a Datasource you write to row by row. Rows are keyed by entry_index: a row without one is inserted, a row with one is upserted. deleteRows() soft-deletes rows by entry_index. upsertRows() validates every value against the field types before sending anything, then writes in batches of 500. Datagraph provisioning. upsertByName() on Datagraph Objects and Datagraph Object Families creates or updates by name, then publishes if you pass publish: true. Running the same script twice gives the same result, which suits environment promotion and CI. Local checks. datagraph.schema.validateLocal() checks a Datagraph Schema without any request. datagraph.objects.lintSql(), datagraph.objects.inferAnswers() and datagraph.objectFamilies.checkConformance() check a Datagraph Object against the live Datagraph Schema (fetched when you do not pass one) and return the same issues as the Datagraph editor, before anything is saved. Pagination. List calls return { items, count, page, perPage }. query.iterateRows() is an async generator over every page.

Errors