# `Mutare.Ecto.QueryTerminal`
[🔗](https://github.com/foxbenjaminfox/mutare_ecto/blob/v0.4.2/lib/mutare/ecto/query_terminal.ex#L1)

Swap `Ecto.Query.first/1,2` ↔ `Ecto.Query.last/1,2` — the query "terminals" that restrict a
query to a single edge of its ordering. `first` keeps the first row by the order (primary key
ascending when none is given); `last` reverses it. Swapping them is a clean, same-arity rename
(so it always compiles), behaviour-changing whenever the query can return more than one row — a
survivor means no test pins *which* end the query is taking.

These are plain `Ecto.Query` functions (not the macro DSL), so they resolve through
`Mutare.Calls.resolved_call_to/3` in every written form — qualified (`Ecto.Query.first(q)`),
aliased, or bare under `import Ecto.Query` — and use Mutare's ordinary in-place selector. The
`rebuild` keeps the source's written form (and is pipe-agnostic: `q |> first()` has an empty arg
list, so `q |> last()` falls out for free). Family `:query_terminal`.

# `mutations`

```elixir
@spec mutations(Macro.t(), Mutare.Ecto.Context.t()) :: [Mutare.Ecto.Tag.t()]
```

First↔last swap for an `Ecto.Query` terminal call as a `:query_terminal` tag, or `[]`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
