TypedGql.VariablesDumper (TypedGql v0.13.0)

Copy Markdown View Source

Dumps a variables struct to wire JSON, keeping only the keys the caller actually provided.

Ecto.embedded_dump/2 emits every schema field, which turns an omitted optional input field into an explicit null on the wire. GraphQL distinguishes the two: absent means "not given", while null can mean "clear this value" in an update mutation. Pruning the dump against the original params preserves the distinction — a key the caller passed (even as nil) is sent, a key they omitted is not.

Params are read the way Ecto.Changeset.cast/3 reads them: a field is looked up under its atom name and then under its string name, so atom keys, string keys, and a mix of the two across nesting levels all work.

Summary

Functions

dump(variables, params)

@spec dump(
  struct(),
  map()
) :: map()