Last active
October 7, 2022 15:00
-
-
Save mecid/6b19cc006939855748604de16bf12eca to your computer and use it in GitHub Desktop.
Apollo GraphQL Run Script for Xcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go to the build root and search up the chain to find the Derived Data Path where the source packages are checked out. | |
DERIVED_DATA_CANDIDATE="${BUILD_ROOT}" | |
while ! [ -d "${DERIVED_DATA_CANDIDATE}/SourcePackages" ]; do | |
if [ "${DERIVED_DATA_CANDIDATE}" = / ]; then | |
echo >&2 "error: Unable to locate SourcePackages directory from BUILD_ROOT: '${BUILD_ROOT}'" | |
exit 1 | |
fi | |
DERIVED_DATA_CANDIDATE="$(dirname "${DERIVED_DATA_CANDIDATE}")" | |
done | |
# Grab a reference to the directory where scripts are checked out | |
SCRIPT_PATH="${DERIVED_DATA_CANDIDATE}/SourcePackages/checkouts/apollo-ios/scripts" | |
if [ -z "${SCRIPT_PATH}" ]; then | |
echo >&2 "error: Couldn't find the CLI script in your checked out SPM packages; make sure to add the framework to your project." | |
exit 1 | |
fi | |
cd "${SRCROOT}/${TARGET_NAME}" | |
"${SCRIPT_PATH}"/run-bundled-codegen.sh schema:download --endpoint=https://swapi-graphql.netlify.app/.netlify/functions/index/query schema.json | |
"${SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="schema.json" API.swift |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment