Zendro-dev / graphql-server-model-codegen

Command line utility to auto-generate the structure files for a graphql server
MIT License
1 stars 2 forks source link

feat: add support for multiple database connections #146

Closed davelsan closed 4 years ago

davelsan commented 4 years ago

Issue

This PR addresses issue #143.

Description

GMSC Issue 143

This PR implements the code generator changes necessary to query arbitrary local database connections defined at the data models layer. It also synchronizes graphql-server-model-codegen with changes in branch graphql-server#143-multiple-databases.

Integration Tests Changes

Because there is now a static models/adapters/index.js file in the graphql-server, the previous method of mounting generated code folders into the Docker image is no longer possible.

This has led to a different strategy for setting server instances dynamically, in addition to some improvements and optimizations to the integration tests CLI. The API remains mostly the same, with the flags we know and have been using until now having the same functionality.

To run integration tests using a specific graphql-server branch, the Dockerfile.graphql_server image file no longer needs to be modified. In fact, the server repository is no longer cloned in the image, which now only provides environment and tooling. An additional -b <branch> flag has been added to that effect.

# To execute a default run using the relevant branch for this PR
npm run test-integration -b "issue#143-multiple-databases"

# To execute a "keep containers alive" run
npm run test-integration -b "issue#143-multiple-databases" -k

# To execute a "generate code and run tests" and "keep containers alive"
npm run test-integration -b "issue#143-multiple-databases" -T -k

Other flags have also been added for a more modular functionality:

# To generate code only (this no longer ups the containers, as it was redundant with the other compatible flags)
npm run test-integration -g

# To clean up the generated code only
npm run test-integration -C

# To perform an initial setup: clones the server and re-creates instances
npm run test-integration -s

# Alternatively, an initial setup is compatible with the -b flag
npm run test-integration -b "issue#143-multiple-databases" -s

See the attached diagram for a visual explanation of how the API works. fzj-zendro-integration-tests-cli.pdf

Blocks

Notes

davelsan commented 4 years ago

Fixed the issues we talked about.

Changes since last revision:

davelsan commented 4 years ago

Fixed remaining issues and bumped to 0.3.0.

Should be ready to merge along with graphql-server#42-multiple-databases