Permalink
Browse files

GraphQL Server (#1603)

* Add GraphQL express/apollo server generator

* add basic resolvers; adjust parameters/input types

* small adjustments and improvements

* adjust logger config for GraphQL generators

* remove MaxPermSize form bash script as it will be removed from later Java versions; add isNullable utility helper method; Adjust TODOs for graphql implementation

* re-created samples for graphql config and server generators

* re-added templates for graphql config generator

* add graphql-config-petstore bash script

* add isNullable utility method

* fix javadoc issues

* adjust licence headers

* rename Generator to Codegen for GraphQL classes

* renaming, minor enhancement to graphql generator

* add graphql server samples

* add windows batch files, rename directory
  • Loading branch information...
wing328 committed Dec 5, 2018
1 parent 01ac429 commit 4be605bcb725bda887bb8e387e73a5fabc3c9282
Showing with 5,710 additions and 1 deletion.
  1. +32 −0 bin/graphql-schema-petstore.sh
  2. +32 −0 bin/graphql-server-petstore.sh
  3. +42 −0 bin/openapi3/graphql-petstore-server.sh
  4. +10 −0 bin/windows/graphql-petstore-server.bat
  5. +10 −0 bin/windows/graphql-schema-petstore.bat
  6. +463 −0 ...es/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGraphQLCodegen.java
  7. +90 −0 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GraphQLSchemaCodegen.java
  8. +147 −0 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GraphQLServerCodegen.java
  9. +16 −0 modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java
  10. +3 −1 ...les/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
  11. +96 −0 modules/openapi-generator/src/main/resources/graphql-schema/README.mustache
  12. +47 −0 modules/openapi-generator/src/main/resources/graphql-schema/api.mustache
  13. +5 −0 modules/openapi-generator/src/main/resources/graphql-schema/api_doc.mustache
  14. +10 −0 modules/openapi-generator/src/main/resources/graphql-schema/api_test.mustache
  15. +52 −0 modules/openapi-generator/src/main/resources/graphql-schema/git_push.sh.mustache
  16. +40 −0 modules/openapi-generator/src/main/resources/graphql-schema/gitignore.mustache
  17. +33 −0 modules/openapi-generator/src/main/resources/graphql-schema/model.mustache
  18. +11 −0 modules/openapi-generator/src/main/resources/graphql-schema/model_doc.mustache
  19. +23 −0 modules/openapi-generator/src/main/resources/graphql-schema/model_test.mustache
  20. +14 −0 modules/openapi-generator/src/main/resources/graphql-schema/partial_header.mustache
  21. +8 −0 modules/openapi-generator/src/main/resources/graphql-server/.gitignore
  22. +20 −0 modules/openapi-generator/src/main/resources/graphql-server/README.mustache
  23. +55 −0 modules/openapi-generator/src/main/resources/graphql-server/api.mustache
  24. +21 −0 modules/openapi-generator/src/main/resources/graphql-server/api_doc.mustache
  25. +40 −0 modules/openapi-generator/src/main/resources/graphql-server/model.mustache
  26. +11 −0 modules/openapi-generator/src/main/resources/graphql-server/model_doc.mustache
  27. +23 −0 modules/openapi-generator/src/main/resources/graphql-server/model_test.mustache
  28. +25 −0 modules/openapi-generator/src/main/resources/graphql-server/package.json.mustache
  29. +11 −0 modules/openapi-generator/src/main/resources/graphql-server/partial_header.mustache
  30. +9 −0 modules/openapi-generator/src/main/resources/graphql-server/partial_header_graphql.mustache
  31. +34 −0 modules/openapi-generator/src/main/resources/graphql-server/resolvers.mustache
  32. +3 −0 modules/openapi-generator/src/main/resources/graphql-server/schema.graphql.mustache
  33. +37 −0 modules/openapi-generator/src/main/resources/graphql-server/server.js
  34. +7 −0 modules/openapi-generator/src/main/resources/graphql-server/start.js
  35. +11 −0 modules/openapi-generator/src/main/resources/graphql-server/type-defs.mustache
  36. +23 −0 samples/config/petstore/graphql-schema/.openapi-generator-ignore
  37. +1 −0 samples/config/petstore/graphql-schema/.openapi-generator/VERSION
  38. +64 −0 samples/config/petstore/graphql-schema/petstore/api/pet_api.graphql
  39. +38 −0 samples/config/petstore/graphql-schema/petstore/api/store_api.graphql
  40. +60 −0 samples/config/petstore/graphql-schema/petstore/api/user_api.graphql
  41. +16 −0 samples/config/petstore/graphql-schema/petstore/model/api_response.graphql
  42. +14 −0 samples/config/petstore/graphql-schema/petstore/model/category.graphql
  43. +30 −0 samples/config/petstore/graphql-schema/petstore/model/order.graphql
  44. +30 −0 samples/config/petstore/graphql-schema/petstore/model/pet.graphql
  45. +14 −0 samples/config/petstore/graphql-schema/petstore/model/tag.graphql
  46. +27 −0 samples/config/petstore/graphql-schema/petstore/model/user.graphql
  47. +23 −0 samples/server/petstore/graphql-server/.openapi-generator-ignore
  48. +1 −0 samples/server/petstore/graphql-server/.openapi-generator/VERSION
  49. +12 −0 samples/server/petstore/graphql-server/docs/ApiResponse.md
  50. +11 −0 samples/server/petstore/graphql-server/docs/Category.md
  51. +11 −0 samples/server/petstore/graphql-server/docs/InlineObject.md
  52. +11 −0 samples/server/petstore/graphql-server/docs/InlineObject1.md
  53. +15 −0 samples/server/petstore/graphql-server/docs/Order.md
  54. +15 −0 samples/server/petstore/graphql-server/docs/Pet.md
  55. +11 −0 samples/server/petstore/graphql-server/docs/Tag.md
  56. +17 −0 samples/server/petstore/graphql-server/docs/User.md
  57. +62 −0 samples/server/petstore/graphql-server/docs/pet_api.md
  58. +38 −0 samples/server/petstore/graphql-server/docs/store_api.md
  59. +62 −0 samples/server/petstore/graphql-server/docs/user_api.md
  60. +8 −0 samples/server/petstore/graphql-server/openapi3graphql-server/.gitignore
  61. +18 −0 samples/server/petstore/graphql-server/openapi3graphql-server/README.md
  62. +97 −0 samples/server/petstore/graphql-server/openapi3graphql-server/api/pet_api.graphql
  63. +86 −0 samples/server/petstore/graphql-server/openapi3graphql-server/api/pet_api_resolver.js
  64. +50 −0 samples/server/petstore/graphql-server/openapi3graphql-server/api/store_api.graphql
  65. +53 −0 samples/server/petstore/graphql-server/openapi3graphql-server/api/store_api_resolver.js
  66. +85 −0 samples/server/petstore/graphql-server/openapi3graphql-server/api/user_api.graphql
  67. +83 −0 samples/server/petstore/graphql-server/openapi3graphql-server/api/user_api_resolver.js
  68. +22 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/api_response.graphql
  69. +20 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/category.graphql
  70. +23 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/inline_object.graphql
  71. +23 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/inline_object_1.graphql
  72. +37 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/order.graphql
  73. +37 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/pet.graphql
  74. +20 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/tag.graphql
  75. +34 −0 samples/server/petstore/graphql-server/openapi3graphql-server/model/user.graphql
  76. +2,123 −0 samples/server/petstore/graphql-server/openapi3graphql-server/package-lock.json
  77. +25 −0 samples/server/petstore/graphql-server/openapi3graphql-server/package.json
  78. +3 −0 samples/server/petstore/graphql-server/openapi3graphql-server/schema.graphql
  79. +37 −0 samples/server/petstore/graphql-server/openapi3graphql-server/server.js
  80. +7 −0 samples/server/petstore/graphql-server/openapi3graphql-server/start.js
  81. +8 −0 samples/server/petstore/graphql-server/petstore/.gitignore
  82. +18 −0 samples/server/petstore/graphql-server/petstore/README.md
  83. +97 −0 samples/server/petstore/graphql-server/petstore/api/pet_api.graphql
  84. +86 −0 samples/server/petstore/graphql-server/petstore/api/pet_api_resolver.js
  85. +50 −0 samples/server/petstore/graphql-server/petstore/api/store_api.graphql
  86. +53 −0 samples/server/petstore/graphql-server/petstore/api/store_api_resolver.js
  87. +85 −0 samples/server/petstore/graphql-server/petstore/api/user_api.graphql
  88. +83 −0 samples/server/petstore/graphql-server/petstore/api/user_api_resolver.js
  89. +22 −0 samples/server/petstore/graphql-server/petstore/model/api_response.graphql
  90. +20 −0 samples/server/petstore/graphql-server/petstore/model/category.graphql
  91. +37 −0 samples/server/petstore/graphql-server/petstore/model/order.graphql
  92. +37 −0 samples/server/petstore/graphql-server/petstore/model/pet.graphql
  93. +20 −0 samples/server/petstore/graphql-server/petstore/model/tag.graphql
  94. +34 −0 samples/server/petstore/graphql-server/petstore/model/user.graphql
  95. +25 −0 samples/server/petstore/graphql-server/petstore/package.json
  96. +3 −0 samples/server/petstore/graphql-server/petstore/schema.graphql
  97. +37 −0 samples/server/petstore/graphql-server/petstore/server.js
  98. +7 −0 samples/server/petstore/graphql-server/petstore/start.js
@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties $@"
ags="generate -t modules/openapi-generator/src/main/resources/graphql-schema -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g graphql-schema -o samples/config/petstore/graphql-schema -DpackageName=petstore $@"
java $JAVA_OPTS -jar $executable $ags
@@ -0,0 +1,32 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties $@"
ags="generate -t modules/openapi-generator/src/main/resources/graphql-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g graphql-server -o samples/server/petstore/graphql-server -DpackageName=petstore $@"
java $JAVA_OPTS -jar $executable $ags
@@ -0,0 +1,42 @@
#!/bin/bash
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
# Make sure that the working directory is the root dir
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${SCRIPT_DIR}/../"
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
# Make sure that we are regenerating the sample by removing any existing target directory
TARGET_DIR="$SCRIPT_DIR/../../samples/server/petstore/graphql-server"
if [ -d "$TARGET_DIR" ]; then
rm -rf $TARGET_DIR
fi
executable="$SCRIPT_DIR/../../modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t $SCRIPT_DIR/../../modules/openapi-generator/src/main/resources/graphql-server -i $SCRIPT_DIR/../../modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g graphql-server -o $TARGET_DIR $@"
java $JAVA_OPTS -jar $executable $ags
@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -t modules\openapi-generator\src\main\resources\graphql-server -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g graphql-server -o samples\server\petstore\graphql-server
java %JAVA_OPTS% -jar %executable% %ags%
@@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -t modules\openapi-generator\src\main\resources\graphql-schema -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g graphql-schema -o samples\config\petstore\graphql-schema
java %JAVA_OPTS% -jar %executable% %ags%
Oops, something went wrong.

0 comments on commit 4be605b

Please sign in to comment.