Skip to content

Commit

Permalink
feat: flat search input value (#62)
Browse files Browse the repository at this point in the history
* refactor: support flat search input value field

* i142 - added manadatory pagination arguments (partial) - fixed integration test environment

* removed debug lines

* remove quotes from Array value type

* chore: bump to 0.3.0

* fix: change test branch to master

* chore: version bump to 0.4.0

Co-authored-by: Francisco Ramírez <[email protected]>
  • Loading branch information
davelsan and framirez07 authored Sep 11, 2020
1 parent a011eaf commit 1125784
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 231 deletions.
6 changes: 3 additions & 3 deletions docker/copy_generated_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ TARGET_DIRS=(
"schemas" \
"resolvers" \
"models/sql" \
"models/adapters" \
"migrations" \
"validations" \
"patches")
GENERATED_CODE_DIR="./generated"
GENERATED_CODE_DIR="./generated"
RED='\033[0;31m'
LGREEN='\033[1;32m'
YEL='\033[1;33m'
Expand All @@ -35,7 +35,7 @@ do
if [ -d ./${i} ]; then

#remove
find ./${i} -type f \! -name '20200715195822-role\.js' \! -name 'role\.js' \! -name '20200715195823-role_to_user\.js' \! -name 'role_to_user\.js' \! -name '20200715195823-user\.js' \! -name 'user\.js' -exec rm -rf '{}' \;
find ./${i} -type f \! -name '20200715195822-role\.js' \! -name 'role\.js' \! -name '20200715195823-role_to_user\.js' \! -name 'role_to_user\.js' \! -name '20200715195823-user\.js' \! -name 'user\.js' \! -name 'index\.js' -exec rm -vrf '{}' \;
if [ $? -eq 0 ]; then
echo -e "@ Removed content in: ${i} ... ${LGREEN}done${NC}"
else
Expand All @@ -44,7 +44,7 @@ do
fi

#copy
cp ${GENERATED_CODE_DIR}/${i}/* ./${i}/
cp -r ${GENERATED_CODE_DIR}/${i}/* ./${i}/
if [ $? -eq 0 ]; then
echo -e "@ Copied generated code into: ./${i} ... ${LGREEN}done${NC}"
else
Expand Down
8 changes: 4 additions & 4 deletions docker/docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ services:
dockerfile: Dockerfile.graphql_server

volumes:
- ./integration_test_run/gql-instance1/models/adapters:/usr/src/app/models/adapters
- ./integration_test_run/gql-instance1/schemas:/usr/src/app/generated/schemas
- ./integration_test_run/gql-instance1/resolvers:/usr/src/app/generated/resolvers
- ./integration_test_run/gql-instance1/models/sql:/usr/src/app/generated/models/sql
- ./integration_test_run/gql-instance1/models/adapters:/usr/src/app/generated/models/adapters
- ./integration_test_run/gql-instance1/models/distributed:/usr/src/app/models/distributed
- ./integration_test_run/gql-instance1/models/zendro-server:/usr/src/app/models/zendro-server
- ./integration_test_run/gql-instance1/models/generic:/usr/src/app/models/generic
- ./integration_test_run/gql-instance1/migrations:/usr/src/app/generated/migrations
- ./integration_test_run/gql-instance1/validations:/usr/src/app/generated/validations
- ./integration_test_run/gql-instance1/patches:/usr/src/app/generated/patches
- ./integration_test_run/gql-instance1/acl_rules.js:/usr/src/app/acl_rules.js
- ./sequelize_config_instance1.json:/usr/src/app/config/config.json
- ./sequelize_config_instance1.json:/usr/src/app/config/data_models_storage_config.json
- ./copy_generated_code.sh:/usr/src/app/copy_generated_code.sh
- ./migrateDbAndStartServer.sh:/usr/src/app/migrateDbAndStartServer.sh

Expand Down Expand Up @@ -168,7 +168,7 @@ services:
dockerfile: Dockerfile.graphql_server

volumes:
- ./integration_test_run/gql-instance2/models/adapters:/usr/src/app/models/adapters
- ./integration_test_run/gql-instance2/models/adapters:/usr/src/app/generated/models/adapters
- ./integration_test_run/gql-instance2/schemas:/usr/src/app/generated/schemas
- ./integration_test_run/gql-instance2/resolvers:/usr/src/app/generated/resolvers
- ./integration_test_run/gql-instance2/models/sql:/usr/src/app/generated/models/sql
Expand All @@ -179,7 +179,7 @@ services:
- ./integration_test_run/gql-instance2/validations:/usr/src/app/generated/validations
- ./integration_test_run/gql-instance2/patches:/usr/src/app/generated/patches
- ./integration_test_run/gql-instance2/acl_rules.js:/usr/src/app/acl_rules.js
- ./sequelize_config_instance2.json:/usr/src/app/config/config.json
- ./sequelize_config_instance2.json:/usr/src/app/config/data_models_storage_config.json
- ./copy_generated_code.sh:/usr/src/app/copy_generated_code.sh

ports:
Expand Down
72 changes: 51 additions & 21 deletions docker/migrateDbAndStartServer.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
#!/bin/bash
#!/usr/bin/env bash

# Wait until the relational database-server up and running
waited=0
until node ./utils/testSequelizeDbServerAvailable.js
until node ./scripts/testDatabaseConnectionsAvailable.js 1>/dev/null
do
if [ $waited == 240 ]; then
echo -e '\nERROR: Time out reached while waiting for relational database server to be available.\n'
exit 1
fi
sleep 2
waited=$(expr $waited + 2)
if [ $waited == 240 ]; then
echo -e '\nERROR: Time out reached while waiting for relational database server to be available.\n'
exit 1
fi
sleep 2
waited=$(expr $waited + 2)
done

# Run the migrations
if ! ./node_modules/.bin/sequelize db:migrate; then
echo -e '\nERROR: Migrating the relational database(s) caused an error.\n'
exit 1
fi

# Run seeders if needed
if [ -d ./seeders ]; then
if ! ./node_modules/.bin/sequelize db:seed:all; then
echo -e '\nERROR: Seeding the relational database(s) caused an error.\n'
exit 1
fi
fi
# Read config and migrate/seed databases
CONFIG="./config/data_models_storage_config.json"
SEQUELIZE="./node_modules/.bin/sequelize"
DB_KEYS=( $(node ./scripts/getStorageTypes.js) )

for object in ${DB_KEYS[@]}; do

# Split "key:storageType" in each DB_KEYS element
params=(${object//:/ })

# Retrieve individual values
key="${params[0]}"
storageType="${params[1]}"

# Execute sequelize CLI
sequelize_params=(
"--config $CONFIG"
"--env $key"
"--migrations-path ./migrations/$key/"
"--seeders-path ./seeders/$key/"
)

if [[ "$storageType" == "sql" ]]; then

# Run the migrations
if ! $SEQUELIZE db:migrate ${sequelize_params[@]}; then
echo -e '\nERROR: Migrating the relational database(s) caused an error.\n'
exit 1
fi

# Run seeders if needed
if [ -d ./seeders/$key ]; then
if ! $SEQUELIZE db:seed:all ${sequelize_params[@]}; then
echo -e '\nERROR: Seeding the relational database(s) caused an error.\n'
exit 1
fi
fi

fi

done


# Start GraphQL-server
npm start acl
npm start acl
22 changes: 3 additions & 19 deletions docker/sequelize_config_instance1.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
{
"development": {
"default-sql": {
"storageType": "sql",
"username": "sciencedb",
"password": "sciencedb",
"database": "sciencedb_development",
"host": "gql_postgres1",
"dialect": "postgres",
"operatorsAliases": false
},
"test": {
"username": "sciencedb",
"password": "sciencedb",
"database": "sciencedb_test",
"host": "gql_postgres1",
"dialect": "postgres",
"operatorsAliases": false
},
"production": {
"username": "sciencedb",
"password": "sciencedb",
"database": "sciencedb_production",
"host": "gql_postgres1",
"dialect": "postgres",
"operatorsAliases": false
"dialect": "postgres"
}
}
24 changes: 4 additions & 20 deletions docker/sequelize_config_instance2.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
{
"development": {
"default-sql": {
"storageType": "sql",
"username": "sciencedb",
"password": "sciencedb",
"database": "sciencedb_development",
"host": "gql_postgres2",
"dialect": "postgres",
"operatorsAliases": false
},
"test": {
"username": "sciencedb",
"password": "sciencedb",
"database": "sciencedb_test",
"host": "gql_postgres2",
"dialect": "postgres",
"operatorsAliases": false
},
"production": {
"username": "sciencedb",
"password": "sciencedb",
"database": "sciencedb_production",
"host": "gql_postgres2",
"dialect": "postgres",
"operatorsAliases": false
"dialect": "postgres"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "single-page-app-codegen",
"version": "0.2.0",
"version": "0.4.0",
"description": "Enables auto generation of basic List, Create, Edit, and Delete Views for data models.",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 1125784

Please sign in to comment.