# @orbitalhq/orbital-client

> A library to execute TaxiQL queries against an Orbital query server

Latest version **0.1.1** (published 2025-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @orbitalhq/orbital-client
pnpm add @orbitalhq/orbital-client
yarn add @orbitalhq/orbital-client
bun add @orbitalhq/orbital-client
```

Provides the command `orbital-generate`.

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2025-01-14 |
| First published | 2023-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 106.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | marty.pitt, jasonl_orbital |
| Keywords | orbital |

## Links

- npm: https://www.npmjs.com/package/@orbitalhq/orbital-client
- Repository: https://github.com/orbitalapi/typescript-client
- Homepage: https://orbitalhq.com
- Issues: https://github.com/orbitalapi/typescript-client/issues
- npm.io page: https://npm.io/package/@orbitalhq/orbital-client

## Recent versions

- 0.1.1 (latest) — 2025-01-14
- 0.1.0-alpha.2 — 2023-03-15
- 0.1.0-alpha.1 — 2023-02-23
- 0.1.0-alpha.0 — 2023-01-23

## README

# Orbital TypeScript client

A library to execute TaxiQL queries against the Orbital query server.

## Getting started

Install the dependency with

```bash
npm install @orbitalhq/orbital-client
```

and create a file called `orbital.config.json` to the same folder that contains `package.json` with the following
content:

```json
{
  "orbitalServerUrl": "<SCHEMA_SERVER_URL>"
}
```

where you replace `<SCHEMA_SERVER_URL>` with the URL of the schema server
like `http://schema-server.orbital.example.com`.

Finally, run

```bash
npm run orbital:taxonomy:generate
```

This will generate a taxonomy file called `taxonomy.ts` next to `package.json`. This file should be committed to version
control and be updated (by re-running `npm run orbital:taxonomy:generate`) whenever the schema changes.

Once the taxonomy file is generated, you can initialize the client:

```typescript
import { asArray, buildClient, consoleLogger, HttpQueryClient } from 'orbital-client';
import { taxonomy } from './taxonomy';

const client = buildClient<{}, typeof taxonomy>(
  taxonomy,
  new HttpQueryClient('http://localhost:9022'),
  {
    logger: consoleLogger,
  },
);
```

and start executing queries

```typescript
client
  .given(taxonomy.people.FirstName, 'John')
  .find(asArray(taxonomy.people.Person))
  .execute()
  .subscribe((result) => console.log(result[0].firstName));
```

which sends the following TaxiQL query to be executed on the Orbital server:

```
given {
        people.FirstName = "John"
}
find { people.Person[] }
```

You can also access this query by calling `.toTaxiQL()` on the query builder.

```typescript
const query = client
  .given(taxonomy.people.FirstName, 'John')
  .find(asArray(taxonomy.people.Person))
  .toTaxiQl();
console.log(query);
```

---
_Source: https://npm.io/package/@orbitalhq/orbital-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
