Skip to content

Commit bae6c1b

Browse files
committed
first complete version of generator framework
1 parent b2e98a1 commit bae6c1b

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

graphql-server/empty_custom_api_schema.graphql

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
get: function(options) {
3+
return {
4+
Query: {}
5+
};
6+
}
7+
};

graphql-server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const graphqlResolvers = require('./resolvers.js');
55
const graphqlCustomResolvers = require('./custom-resolvers.js');
66

77
const text = fs.readFileSync('api-schema/api-schema.graphql', 'utf8');
8-
const textExtend = fs.readFileSync('api-schema/custom-extensions.graphql', 'utf8');
8+
const textExtend = fs.readFileSync('api-schema/custom-api-schema.graphql', 'utf8');
99
const typeDefs = gql`${text + textExtend}`;
1010

1111
async function run(){

woo.sh

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ info "arg_n: ${arg_n}"
416416
# woo.sh
417417
echo "Now ready for GrahpQL server generation!"
418418

419-
input_dir=${arg_i}
420419
config_file="$(cd "$(dirname "${arg_c}")" && pwd)/$(basename "${arg_c}")"
421420

422421
# Check if driver exists
@@ -434,7 +433,7 @@ output_dir=$(cd ${arg_o}; pwd)
434433
if [[ -n "${arg_s}" ]]; then
435434
custom_schema=${arg_s}
436435
else
437-
custom_schema=${__dir}/graphql-server/empty_custom_schema.graphql
436+
custom_schema=${__dir}/graphql-server/empty_custom_api_schema.graphql
438437
fi
439438

440439
# custom API resolvers
@@ -444,9 +443,34 @@ else
444443
custom_resolvers=${__dir}/graphql-server/empty_custom_resolvers.js
445444
fi
446445

447-
echo ${input_dir}
446+
echo ${arg_i}
448447
echo ${config_file}
449448
echo ${driver_dir}
450449
echo ${output_dir}
451450
echo ${custom_schema}
452-
echo ${custom_resolvers}
451+
echo ${custom_resolvers}
452+
453+
# copy server files
454+
cp ./graphql-server/server.js ${output_dir}
455+
cp ${driver_dir}/* ${output_dir}
456+
(cd ${output_dir}; npm install)
457+
# Hack: Modify executeFieldsSerially(...) in /node_modules/graphql/execution/execute.js
458+
# The mod is required to support nested transactions.
459+
cp ./graphql-server/graphql/execution/execution.js ${output_dir}/node_modules/graphql/execution/execute.js
460+
cp ${custom_schema} ${output_dir}/api-schema/custom-api-schema.graphql
461+
cp ${custom_resolvers} ${output_dir}/custom-resolvers.js
462+
463+
# generate GraphQL API schema (for now, assume that arg_i is a relative path/file)
464+
cd ./graphql-api-generator
465+
python3 generator.py \
466+
--input ../${arg_i} \
467+
--output ${output_dir}/api-schema/api-schema.graphql \
468+
--config ${config_file}
469+
cd ..
470+
471+
# generate resolvers
472+
cd ./graphql-resolver-generator
473+
python3 generator.py \
474+
--input ${output_dir}/api-schema/api-schema.graphql \
475+
--output ${output_dir}
476+
cd ..

0 commit comments

Comments
 (0)