mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
69c8e8bb4a
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8238 GitOrigin-RevId: 9a4730e0d311916c0d837586485382c58033c914
31 lines
902 B
Bash
Executable File
31 lines
902 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Get path to schema file as an argument, and expand the path relative to the
|
|
# working directory the script was run from.
|
|
SCHEMA_FILE=$(readlink -f "$1")
|
|
|
|
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" # ... https://stackoverflow.com/a/246128/176841
|
|
cd "$PROJECT_ROOT/typescript"
|
|
|
|
echo "Deleting existing generated model..."
|
|
rm -rf src
|
|
echo "Generating model from $SCHEMA_FILE..."
|
|
npx openapi \
|
|
--useUnionTypes \
|
|
--input "$SCHEMA_FILE" \
|
|
--output src \
|
|
--exportServices false \
|
|
--exportCore false \
|
|
--indent 2
|
|
|
|
# To make a patch, commit the unpatched file, make the changes you want, and run
|
|
# `git diff > patches/my-patch.patch`
|
|
echo "Applying patches to generated files..."
|
|
for PATCH in patches/*.patch; do
|
|
# Don't crash if there are no patches.
|
|
if [ -f "$PATCH" ]; then
|
|
git apply "$PATCH"
|
|
fi
|
|
done
|