# Mutation Generation

## How to Generate

For each resolver doc at `<app>/docs/resolvers/*.md`:

1. Read the resolver doc to find the mutation name (usually `create<EntityName>`)
2. Introspect the schema to get the exact input type:
   ```graphql
   query {
     __type(name: "Create<EntityName>Input") {
       inputFields { name type { name kind ofType { name kind } } }
     }
   }
   ```
3. Generate a minimal mutation file

## Mutation File Format

File: `ingest/mutations/create<EntityName>.graphql`

```graphql
mutation Create<EntityName>($input: Create<EntityName>Input!) {
  create<EntityName>(input: $input) {
    id
  }
}
```

## Rules

- One mutation per file
- File name matches the mutation name: `createSalesOrder.graphql` for `createSalesOrder`
- Only request `id` in the response — gql-ingest doesn't use response data in v1
- The mutation variable is always `$input` with the full input type
- Input type name comes from schema introspection, not guessed

## Non-Create Mutations

If a resolver doc describes a non-create mutation (e.g., `updateOrderStatus`, `approveInvoice`), generate it the same way but with the correct mutation name and input type. These are useful in scenarios that exercise state transitions.
