# GraphQL Client Operation Regression Gate (`bread-kim/graphql-client-operation-regression-gate`) Actor

Detect GraphQL client operations that break after schema changes. Distinguish new regressions from existing errors and report exact files, source locations, variables, fragments, plus SARIF, JUnit, JSON, and Markdown outputs for CI.

- **URL**: https://apify.com/bread-kim/graphql-client-operation-regression-gate.md
- **Developed by:** [bread kim](https://apify.com/bread-kim) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GraphQL Client Operation Regression Gate

A private, deterministic Apify Actor that checks **actual named client operations** against inline before/after GraphQL SDL. It separates defects already present in the baseline from operations made invalid by the candidate schema, validates bounded variable cases independently against both versions, and emits source-hashed JSON, SARIF 2.1.0, JUnit XML, and Markdown evidence.

It is intentionally not a schema-diff clone and never contacts or executes a GraphQL endpoint. It does not run resolvers, custom directives, customer code, commands, URLs, or suggested fixes. Validation uses the official MIT-licensed `graphql` (graphql-js) package pinned to `17.0.2`.

### Input and result

Supply `beforeSdl`, `afterSdl`, at least one `{ path, source }` document, and optionally named variable cases. Paths are safe virtual labels; no source file is opened. Cross-file fragments work because all named documents are parsed into one bounded corpus while their original `Source` objects retain exact line/column locations. Every GraphQL `NAME` token is limited to 256 characters before schema or document parsing, and variable-case `operationName` references use the same limit.

The authoritative status is:

- `REGRESSIONS_FOUND`: at least one operation was valid before but invalid after.
- `BASELINE_INVALID`: no new regression exists, but at least one operation or variable case was already invalid before. This is never reported as compatible.
- `PASS`: every operation and applicable variable case is valid in both schemas.

`NOT_RUNTIME_VALIDATED` means a variable case reaches a custom scalar whose application-specific coercion cannot be reproduced from SDL. It is not treated as proof of runtime validity. The product makes no claim about resolver behavior, response values, performance, directives with application code, or runtime equivalence.

Useful regression findings are a successful analysis result and are saved normally. A missing Actor `INPUT` writes only an honest `OUTPUT` error with code `INVALID_INPUT` and returns normally; it creates no report, dataset item, or billing event. Malformed supplied input remains fatal and produces no dataset/OUTPUT report with a nonzero process exit.

### Local use

```bash
npm_config_cache=.npm-cache npm ci --ignore-scripts
npm run typecheck
npm test
npm run build
node dist/main.js --input examples/input.json --output-dir /tmp/graphql-gate-output
```

The CLI exits `2` for `REGRESSIONS_FOUND`, `0` for `PASS` or baseline-only results, and `1` for fatal malformed input. It writes only four fixed report names under the explicitly supplied output directory. Actor runs instead read `INPUT` and write one default-dataset item plus `OUTPUT`, `REPORT.JSON`, `REPORT.SARIF`, `REPORT.JUNIT.XML`, and `REPORT.MD`.

For the deterministic container-only smoke path:

```bash
docker build -t graphql-client-operation-regression-gate:local .
docker run --rm --network none -e AUTOMATON_CONTAINER_SMOKE=1 graphql-client-operation-regression-gate:local
```

The smoke switch is the only route to its in-memory fixture and makes no storage or network request. No deployment, publishing, billing mutation, scheduling, webhook, proxy, credentials, or paid API is part of this repository.

### Privacy and rights

Only submit schemas and client documents you have the right to process. Inputs and generated reports are retained according to the Apify storage settings of the account running this private Actor. Source bodies and raw variable/argument values are not returned; SHA-256 hashes and exact safe source locations are. Credential-like input is refused, but this is defense in depth rather than a general-purpose secret scanner.

See [REQUIREMENTS.md](REQUIREMENTS.md), [SECURITY_REVIEW.md](SECURITY_REVIEW.md), [QA_REPORT.md](QA_REPORT.md), and [SUPPORT.md](SUPPORT.md).

# Actor input Schema

## `beforeSdl` (type: `string`):

Trusted baseline GraphQL SDL used to identify defects that already existed. Maximum 500000 UTF-8 bytes.

## `afterSdl` (type: `string`):

Candidate GraphQL SDL checked against actual operations. Maximum 500000 UTF-8 bytes.

## `documents` (type: `array`):

Named operation and shared-fragment files. Paths are virtual evidence labels, not files read from disk.

## `variableCases` (type: `array`):

Optional non-secret JSON variable shapes coerced independently against each schema. Raw values are never returned.

## `maxFindings` (type: `integer`):

Caps returned details while status and totals remain based on the complete analysis.

## Actor input object example

```json
{
  "beforeSdl": "input SearchInput { limit: Int! }\ntype Query { user(id: ID!): User search(input: SearchInput!): [User!]! }\ntype User { id: ID! name: String! email: String }",
  "afterSdl": "input SearchInput { limit: Int! }\ntype Query { user(id: ID!): User search(input: SearchInput!): [User!]! }\ntype User { id: ID! name: String! }",
  "documents": [
    {
      "path": "client/fragments/user-card.graphql",
      "source": "fragment UserCard on User { id mail: email }"
    },
    {
      "path": "client/queries/account.graphql",
      "source": "query Account($id: ID!) { user(id: $id) { ...UserCard } }\nquery Healthy($input: SearchInput!) { search(input: $input) { id name } }"
    },
    {
      "path": "client/queries/legacy.graphql",
      "source": "query Legacy { retiredField }"
    }
  ],
  "variableCases": [
    {
      "name": "typical search",
      "operationName": "Healthy",
      "variables": {
        "input": {
          "limit": 10
        }
      }
    }
  ],
  "maxFindings": 500
}
```

# Actor output Schema

## `results` (type: `string`):

Exactly one completed contract result described by the dataset schema.

## `outputRecord` (type: `string`):

Full structured result matching the canary output contract.

## `jsonReport` (type: `string`):

Named JSON copy of the authoritative result.

## `sarifReport` (type: `string`):

SARIF 2.1.0 exact source locations for code scanning.

## `junitReport` (type: `string`):

JUnit XML operation-level CI results.

## `markdownReport` (type: `string`):

Developer-facing classifications, locations and source hashes.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "beforeSdl": `input SearchInput { limit: Int! }
type Query { user(id: ID!): User search(input: SearchInput!): [User!]! }
type User { id: ID! name: String! email: String }`,
    "afterSdl": `input SearchInput { limit: Int! }
type Query { user(id: ID!): User search(input: SearchInput!): [User!]! }
type User { id: ID! name: String! }`,
    "documents": [
        {
            "path": "client/fragments/user-card.graphql",
            "source": "fragment UserCard on User { id mail: email }"
        },
        {
            "path": "client/queries/account.graphql",
            "source": "query Account($id: ID!) { user(id: $id) { ...UserCard } }\nquery Healthy($input: SearchInput!) { search(input: $input) { id name } }"
        },
        {
            "path": "client/queries/legacy.graphql",
            "source": "query Legacy { retiredField }"
        }
    ],
    "variableCases": [
        {
            "name": "typical search",
            "operationName": "Healthy",
            "variables": {
                "input": {
                    "limit": 10
                }
            }
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("bread-kim/graphql-client-operation-regression-gate").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "beforeSdl": """input SearchInput { limit: Int! }
type Query { user(id: ID!): User search(input: SearchInput!): [User!]! }
type User { id: ID! name: String! email: String }""",
    "afterSdl": """input SearchInput { limit: Int! }
type Query { user(id: ID!): User search(input: SearchInput!): [User!]! }
type User { id: ID! name: String! }""",
    "documents": [
        {
            "path": "client/fragments/user-card.graphql",
            "source": "fragment UserCard on User { id mail: email }",
        },
        {
            "path": "client/queries/account.graphql",
            "source": """query Account($id: ID!) { user(id: $id) { ...UserCard } }
query Healthy($input: SearchInput!) { search(input: $input) { id name } }""",
        },
        {
            "path": "client/queries/legacy.graphql",
            "source": "query Legacy { retiredField }",
        },
    ],
    "variableCases": [{
            "name": "typical search",
            "operationName": "Healthy",
            "variables": { "input": { "limit": 10 } },
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("bread-kim/graphql-client-operation-regression-gate").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "beforeSdl": "input SearchInput { limit: Int! }\\ntype Query { user(id: ID!): User search(input: SearchInput!): [User!]! }\\ntype User { id: ID! name: String! email: String }",
  "afterSdl": "input SearchInput { limit: Int! }\\ntype Query { user(id: ID!): User search(input: SearchInput!): [User!]! }\\ntype User { id: ID! name: String! }",
  "documents": [
    {
      "path": "client/fragments/user-card.graphql",
      "source": "fragment UserCard on User { id mail: email }"
    },
    {
      "path": "client/queries/account.graphql",
      "source": "query Account($id: ID!) { user(id: $id) { ...UserCard } }\\nquery Healthy($input: SearchInput!) { search(input: $input) { id name } }"
    },
    {
      "path": "client/queries/legacy.graphql",
      "source": "query Legacy { retiredField }"
    }
  ],
  "variableCases": [
    {
      "name": "typical search",
      "operationName": "Healthy",
      "variables": {
        "input": {
          "limit": 10
        }
      }
    }
  ]
}' |
apify call bread-kim/graphql-client-operation-regression-gate --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bread-kim/graphql-client-operation-regression-gate"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/yu5igQ9QD2AFmpad3/builds/xKKU9Wry5xZMUgAix/openapi.json
