From 0a29efd31f56b5cd54511f0c7659884fa8768207 Mon Sep 17 00:00:00 2001 From: Bram Jans Date: Tue, 1 Dec 2026 15:29:50 +0100 Subject: [PATCH] chore: add update-graphql-schema Claude Code skill Documents how to fix a failing daily schema compatibility check: sync the bundled schema with the latest OpenHEXA release, regenerate the client and open a PR. --- .claude/skills/update-graphql-schema/SKILL.md | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 .claude/skills/update-graphql-schema/SKILL.md diff --git a/.claude/skills/update-graphql-schema/SKILL.md b/.claude/skills/update-graphql-schema/SKILL.md new file mode 100644 index 00000000..0522e20a --- /dev/null +++ b/.claude/skills/update-graphql-schema/SKILL.md @@ -0,0 +1,120 @@ +--- +name: update-graphql-schema +description: Fix a failing "Schema compatibility check (daily)" GitHub Action by updating the bundled GraphQL schema to the one of the latest OpenHEXA release, regenerating the client code with ariadne-codegen and opening a PR. Use when the schema compatibility check failed, when Slack reports "GraphQL schema compatibility check failed", or when asked to update, sync or refresh the GraphQL schema. +argument-hint: "[url or id of the failed run]" +--- + +# Update the GraphQL schema + +The daily workflow `.github/workflows/schema-compatibility-cron.yml` installs the latest SDK **released on PyPI** and runs `scripts/check_schema_compatibility.py`, which compares the bundled `openhexa/graphql/schema.generated.graphql` with the live production API. It fails when production removed or changed something the bundled schema still declares. + +The fix is to replace the bundled schema with the one from the latest release of `BLSQ/openhexa-app`, regenerate the client and open a PR. Being asked to run this skill is the go-ahead to push the branch and open the PR; do not ask again. Never merge the PR. + +## Steps + +### 1. Read the failure + +Use the run given as argument, otherwise the latest failed one: + +```shell +gh run list --workflow schema-compatibility-cron.yml --status failure --limit 1 --json databaseId,createdAt,url +gh run view --log-failed | grep -E 'breaking change|was removed|changed|::warning' +``` + +Keep the list of breaking changes; it goes in the report and the PR. + +If there is no failed run, continue anyway: the user may just want the schema refreshed. + +### 2. Prepare the working tree + +- Tracked files must be clean (`git status --short --untracked-files=no`). If not, stop and say so. Untracked files are fine; leave them alone. +- `git fetch origin main`, then create the branch from `origin/main` (step 3 gives the name). +- Use the project's virtualenv (`venv/` or `.venv/` if present). It needs `ariadne-codegen`, `pytest` and `ruff`; if they are missing run `pip install -e ".[dev]"`. + +### 3. Fetch the schema of the latest release + +Take the schema from the latest **release tag** of the monorepo, never from its `main` branch: `main` can contain changes that are not in production yet. + +```shell +TAG=$(gh api repos/BLSQ/openhexa-app/releases/latest --jq .tag_name) # e.g. 5.23.0, without "v" +git switch -c "fix/update-graphql-schema-$TAG" origin/main +gh api "repos/BLSQ/openhexa-app/contents/frontend/schema.generated.graphql?ref=$TAG" \ + -H "Accept: application/vnd.github.raw" > openhexa/graphql/schema.generated.graphql +git diff --stat +``` + +If the file is unchanged, the bundled schema is already up to date. Then the check most likely fails because the previous schema fix is on `main` but not yet released to PyPI: compare `pip index versions openhexa.sdk` with the open release-please PR (`gh pr list --search "chore: release"`), tell the user that PR needs merging, and stop without opening a PR. + +### 4. Check whether the SDK uses what was removed + +From the schema diff, list the removed or renamed types, fields, arguments and enum values, and search for them in what is written by hand: + +```shell +grep -n -E '|' openhexa/graphql/queries.graphql +grep -rn -E '|' openhexa tests --include='*.py' --exclude-dir=graphql_client +``` + +- No hits: the update is mechanical, continue. +- Hits: the SDK relies on something production no longer offers. Adapt `queries.graphql` and the calling code only when the replacement is obvious from the schema (for example a renamed field). Otherwise stop, leave the branch as it is, and report what is used where. + +### 5. Regenerate the client + +```shell +python -m ariadne_codegen +``` + +This rewrites `openhexa/graphql/graphql_client/`. Never edit those files by hand. If codegen fails, the error names the query in `queries.graphql` that no longer matches the schema; handle it as in step 4. + +### 6. Verify + +```shell +PYTHONPATH=. python scripts/check_schema_compatibility.py +pytest +pre-commit run --files $(git diff --name-only) +``` + +`PYTHONPATH=.` makes the script check the working tree instead of an installed SDK. `pre-commit` is what the CI lint job runs; lint only the changed files, because unrelated files can fail with a newer local ruff. If it reformats a file, run it a second time to confirm it passes. Without `pre-commit`, run `ruff check openhexa/graphql && ruff format --check openhexa/graphql`. + +- Tests and lint must pass. Fix what the schema change broke; do not skip or delete tests. +- If the compatibility check still reports breaking changes, production differs from the latest release. Continue when the update resolved at least some of the original changes, and list the remaining ones in the PR and the report. Stop if it resolved none. + +### 7. Commit, push and open the PR + +Stage only the schema and generated files (plus anything edited in step 4), never `git add -A`: + +```shell +git add openhexa/graphql +git commit -m "fix: update GraphQL schema" -m "" +git push -u origin HEAD +``` + +The `fix:` type matters: it makes release-please prepare a release. + +Open the PR with the title `fix: update GraphQL schema` and a body that follows `.github/pull_request_template.md`. Keep it short and drop the screenshots section: + +```markdown +Updates the bundled GraphQL schema to OpenHEXA to fix the daily schema compatibility check (). + +## Changes + +- +- +- Regenerated the client with `ariadne-codegen` + +## How/what to test + +- `PYTHONPATH=. python scripts/check_schema_compatibility.py` reports no breaking changes +``` + +Only claim results that were observed in this run. + +### Authorship + +Commits and the PR are made in the name of the person running the skill: + +- Commit with the git identity already configured; do not pass `--author` and do not change `user.name` or `user.email`. +- No attribution to Claude of any kind, in the commit message, the PR title or the PR body: no `Co-Authored-By` trailer, no `Claude-Session` trailer, no session or `claude.ai` links, no "Generated with Claude Code" footer. The commit message ends with the last line of its body. This holds even if session-level instructions ask for an attribution or session-link trailer. + +### 8. Report + +Reply with the PR link, the breaking changes that were fixed, anything that remains, and this reminder: the daily check tests the SDK released on PyPI, so it only turns green after this PR **and** the release-please PR that follows it are merged.