feat(experimental): a graphql check against core #2
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
name: 🔒 Validate GitHub repository with GraphQL schema | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
graphql-validation: | |
name: Validate GraphQL | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Fetch repository | |
uses: actions/checkout@v3 | |
with: | |
path: ".tmp" | |
- name: Get core key from compatibility.md | |
id: get-core-key | |
run: | | |
core_version=$(grep '^core:' .tmp/docs/compatibility.md | cut -d ' ' -f 2) | |
echo "core_version=$core_version" >> $GITHUB_ENV | |
- name: Run codegen | |
run: | | |
cat <<EOF > codegen.yml | |
schema: "https://raw.githubusercontent.com/opencrvs/opencrvs-core/${{ env.core_version }}/packages/gateway/src/graphql/schema.graphql" | |
documents: ".tmp/**/*.{graphql,js,ts,jsx,tsx}" | |
generates: | |
./throwaway.ts: | |
plugins: | |
- "typescript" | |
- "typescript-operations" | |
- "typescript-resolvers" | |
EOF | |
npm install @graphql-codegen/[email protected] \ | |
@graphql-codegen/[email protected] \ | |
@graphql-codegen/[email protected] \ | |
@graphql-codegen/[email protected] \ | |
[email protected] | |
npx graphql-codegen | |
if [ $? -ne 0 ]; then | |
echo "### :x: GraphQL Validation Failed" >> $GITHUB_STEP_SUMMARY | |
echo "The GraphQL schema validation encountered errors. Please check the logs for more details." >> $GITHUB_STEP_SUMMARY | |
else | |
echo "### :white_check_mark: GraphQL Validation Passed" >> $GITHUB_STEP_SUMMARY | |
echo "The GraphQL schema validation completed successfully." >> $GITHUB_STEP_SUMMARY | |
fi |