Skip to content

Latest commit

 

History

History
135 lines (89 loc) · 3.3 KB

development.md

File metadata and controls

135 lines (89 loc) · 3.3 KB

Azure Cosmos DB for NoSQL DB Connector

Instructions for developers who wish to contribute or build upon the connector:

Prerequisites

  1. Make sure NodeJS v18+ is installed.
  2. Install Docker

Steps for building and running the connector

Using Docker

  1. Build the dockerfile present in connector-definition/.hasura-connector:
cd connector-definition/.hasura-connector
docker build docker build -t <docker-image-name> .
  1. Run the update command to create a configuration file:
docker run --rm -v ./:/etc/connector/ -e AZURE_COSMOS_KEY=<YOUR_AZURE_COSMOS_KEY> -e AZURE_COSMOS_ENDPOINT=<YOUR_AZURE_COSMOS_ENDPOINT> -e AZURE_COSMOS_DB_NAME=<YOUR_AZURE_DB_NAME> <docker-image-name> update
  1. Run the connector:
docker run --rm -p 8080:8080 -v ./:/etc/connector -e AZURE_COSMOS_KEY=<YOUR_AZURE_COSMOS_KEY> -e AZURE_COSMOS_ENDPOINT=<YOUR_AZURE_COSMOS_ENDPOINT> -e AZURE_COSMOS_DB_NAME=<YOUR_AZURE_DB_NAME> <docker-image-name>

Note, to stop the connector:

  1. Run

    docker ps -a

    and get the connector-name for the

  2. Run

    docker stop <connector-name>

Using CLI

  1. Run the following command to install all the required dependencies:
npm i
  1. To build the connector,
npm run build
  1. Set the following environment variables:
export AZURE_COSMOS_ENDPOINT=<YOUR_AZURE_COSMOS_ENDPOINT>
export AZURE_COSMOS_KEY=<YOUR_AZURE_COSMOS_KEY>
export AZURE_COSMOS_DB_NAME=<YOUR_AZURE_DB_NAME>
  1. Generate the configuration required to run the connector:
npm install -g
ndc-azure-cosmos update

This will generate a config.json file in the root directory, by default. The location of this file can be configured by providing the --output-directory command.

  1. To start the connector,
npm run start serve -- --configuration .

The --configuration directory should contain the configuration file generated in the previous step.

Alternatively, to use a local Azure Cosmos DB for NoSQL emulator, start the connector with the following command,

npm run start serve -- --configuration connector_config_emulator.json

The emulator can be setup by following this link.

Steps to test the connector (ndc-test via emulator)

  1. Make sure that the Azure Cosmos DB for NoSQL emulator is up and running.

  2. Create a database contaner and upload data into the emulator,

cd script
npm i
node app.js
  1. Start the connector using,
npm run build
npm run start serve -- --configuration connector_config_emulator.json
  1. Checkout to the ndc-spec repository and run
cargo run --bin ndc-test -- replay --endpoint http://localhost:8080 --snapshots-dir ../ndc-azure-cosmos-connector/ndc-test-snapshots --no-validate-responses

Note:

  1. The snapshot-dir is the relative path from the ndc-spec repository to the ndc-test-snapshots folder in the ndc-azure-cosmos-connector repository.

  2. --endpoint is the URL at which the connector is running.

Types supported

Scalar types

Currently, the following scalar types are supported:

  1. Integer
  2. Number
  3. String
  4. Boolean