-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (51 loc) · 1.93 KB
/
validate-graphql-queries.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This workflow validates the GraphQL queries against the core schema.
# It gets the linked core version from the compatibility.md file.
name: Validate GraphQL queries
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/cli@5.0.2 \
@graphql-codegen/typescript@4.0.9 \
@graphql-codegen/typescript-operations@4.2.3 \
@graphql-codegen/typescript-resolvers@4.2.1 \
graphql@16.9.0
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