Claude Skill

schema-snapshot

How the GraphQL schema is pinned by a snapshot test - schema.graphql in the integration tests, comparing it with /graphql?sdl, and updating it on purpose when the schema changes. Use when the schema snapshot test fails, or after adding or changing a query, mutation, type, field o

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Download leanmeancleanapps-cleangraphqlapi-.agents_skills_schema-snapshot-1168fea.zip · 0 KB

Install

skills CLI npx skills add https://github.com/LeanMeanCleanApps/CleanGraphQLApi/tree/main/.agents/skills/schema-snapshot
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install leanmeancleanapps-cleangraphqlapi@llmmart
Git git clone https://github.com/LeanMeanCleanApps/CleanGraphQLApi.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole leanmeancleanapps/cleangraphqlapi collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Schema snapshot

The rule

tests/Presentation.Tests.Integration/GraphQL/Schema/schema.graphql is the schema clients see, checked in. SchemaTests.Schema_ShouldMatch_Snapshot asks the running app for /graphql?sdl and fails when the two differ. Every schema change shows up in a pull request as a diff of that file, so reviewers see exactly what clients will see.

The test ignores lines that start with #, which GraphQL treats as comments. In the template repository the snapshot uses them to mark the ApplyPolicy enum, which only exists when authorization is on, so dotnet new can leave it out of a solution created without --include-auth. Keep those markers when you update the snapshot there.

Steps

  1. Make the schema change.
  2. Run the tests. The snapshot test fails and prints the new schema.
  3. Copy the new SDL into schema.graphql. Either take it from the test output, or run the app and open http://localhost:7330/graphql?sdl.
  4. Read the diff. A removed field, a renamed one, or a field that became non-null breaks clients, so say so in the pull request.
  5. Run the tests again.

Don't

  • Update the snapshot without reading the diff.
  • Edit schema.graphql by hand to make the test pass.
  • Skip or delete the snapshot test.

Check

dotnet test tests/Presentation.Tests.Integration --filter "FullyQualifiedName~SchemaTests"
git diff tests/Presentation.Tests.Integration/GraphQL/Schema/schema.graphql
Files (cleangraphqlapi)
  • SKILL.md 1.8 KB
    ---
    name: schema-snapshot
    description: How the GraphQL schema is pinned by a snapshot test - schema.graphql in the integration tests, comparing it with /graphql?sdl, and updating it on purpose when the schema changes. Use when the schema snapshot test fails, or after adding or changing a query, mutation, type, field or description.
    metadata:
      scope: presentation
    ---
    
    # Schema snapshot
    
    ## The rule
    
    `tests/Presentation.Tests.Integration/GraphQL/Schema/schema.graphql` is the schema clients see, checked in. `SchemaTests.Schema_ShouldMatch_Snapshot` asks the running app for `/graphql?sdl` and fails when the two differ. Every schema change shows up in a pull request as a diff of that file, so reviewers see exactly what clients will see.
    
    The test ignores lines that start with `#`, which GraphQL treats as comments. In the template repository the snapshot uses them to mark the `ApplyPolicy` enum, which only exists when authorization is on, so `dotnet new` can leave it out of a solution created without `--include-auth`. Keep those markers when you update the snapshot there.
    
    ## Steps
    
    1. Make the schema change.
    2. Run the tests. The snapshot test fails and prints the new schema.
    3. Copy the new SDL into `schema.graphql`. Either take it from the test output, or run the app and open <http://localhost:7330/graphql?sdl>.
    4. Read the diff. A removed field, a renamed one, or a field that became non-null breaks clients, so say so in the pull request.
    5. Run the tests again.
    
    ## Don't
    
    - Update the snapshot without reading the diff.
    - Edit `schema.graphql` by hand to make the test pass.
    - Skip or delete the snapshot test.
    
    ## Check
    
    ``` bash
    dotnet test tests/Presentation.Tests.Integration --filter "FullyQualifiedName~SchemaTests"
    git diff tests/Presentation.Tests.Integration/GraphQL/Schema/schema.graphql
    ```
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.