Instructions for developers who wish to contribute or build upon the connector:
- Make sure NodeJS v18+ is installed.
- Install Docker
- Build the dockerfile present in
connector-definition/.hasura-connector:
cd connector-definition/.hasura-connector
docker build docker build -t <docker-image-name> .- Run the
updatecommand 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- 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:
-
Run
docker ps -a
and get the connector-name for the
-
Run
docker stop <connector-name>
- Run the following command to install all the required dependencies:
npm i- To build the connector,
npm run build- 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>- Generate the configuration required to run the connector:
npm install -g
ndc-azure-cosmos updateThis 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.
- 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.jsonThe emulator can be setup by following this link.
-
Make sure that the Azure Cosmos DB for NoSQL emulator is up and running.
-
Create a database contaner and upload data into the emulator,
cd script
npm i
node app.js- Start the connector using,
npm run build
npm run start serve -- --configuration connector_config_emulator.json- 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-responsesNote:
-
The
snapshot-diris the relative path from the ndc-spec repository to thendc-test-snapshotsfolder in thendc-azure-cosmos-connectorrepository. -
--endpointis the URL at which the connector is running.
Currently, the following scalar types are supported:
IntegerNumberStringBoolean