Skip to content

bbc - basebox Compiler Reference

Overview

The basebox Compiler exposes the power of PostgreSQL (Postgres) via GraphQL. It does this by taking a novel approach of converting GraphQL to Postgres' Structured Query Language (SQL). In other words, you define the data structures of your application in GraphQL and the Compiler creates the corresponding data model in Postgres. The Compiler also creates a few other files that then goes into running our DBProxy server, thus creating a GraphQL interface to the newly created database. You can then model GraphQL operations that would query and mutation the created database.

If you would like a guided tour of the compiler functionality, please refer to the bbc guide.

basebox Compiler - bbc

The basebox compiler executable bbc takes an annotated GraphQL schema as input and produces files necessary to run the basebox GraphQL server software together with a generated PostgreSQL database/s that the servers connect to.

Usage:

bbc [OPTIONS] <FILENAME>

Arguments:

FILENAME

path and filename of GraphQL schema to compile

Options:

-q, --quiet

quiet operation

-o, --output-directory OUTPUT_DIRECTORY

Output directory for generated files; default is current

-p, --prefix PREFIX

Prefix for file name generation; defaults to the base name of the input file

-f, --force-overwrite

Overwrite existing output files?

-h, --help

Print help (see more with '--help')

-V, --version

Print version stamp

Files Generated

bbc generates the following files:

<PREFIX>-datamodel.sql

The Compiler uses the type definitions in the GraphQL schema file provided to generate a database creation script; this file contains that script. This script needs to be run in PostgreSQL against a database to create the necessary database structures.

<PREFIX>-resolver.toml

The resolver file contains a compiled version of the operation resolvers specified in the scheam file. This is required by the dbproxy in order to fulfill operation requests and is linked to the dbproxy via the dbproxy configuration file.

<PREFIX>-typemap.json

The type map creates a map between GraphQL types and structures and database tables and structures. This is required by dbproxy and is linked to the dbproxy via the dbproxy configuration file.

Note

Together with these three files, the broker and dbproxy also need access to the GraphQL schema file; this is configured in their respective config.toml files.


Last update: 2023-11-14