Skip to content

Send input object fields by schema name - #14636

Merged
vito merged 3 commits into
dagger:mainfrom
vito:fix-input-field-names
Nov 23, 2026
Merged

vito merged 3 commits into
dagger:mainfrom
vito:fix-input-field-names

Conversation

@vito

@vito vito commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

GraphQL input objects (e.g. LLMContentBlockInput { callId, mimeType, ... }, LLMMessageOriginInput { agentName, replyTo, ... }) must be sent with the schema's field names. Some SDKs used the generated identifier instead, so multi-word fields went over the wire as call_id/agent_name, or were dropped.

Found while working on #14501. This PR doesn't depend on it.

Affected SDKs and fixes

  • Rust: input structs have snake_case fields, and serde_graphql_input serialized them as-is (call_id). The generator now emits #[serde(rename = "<schemaName>")] on every input field.
  • Elixir: the query builder encoded input structs by their snake_case keys (agent_name). Generated input modules now define __field_names__/0 (struct key → schema name), and QueryBuilder uses it when it encodes structs. Unset (nil) input fields were also encoded as an empty value (ref:), which is invalid GraphQL; they're now sent as null.
  • Python: cattrs unstructured input dataclasses by attribute name (call_id). graphql-core's ast_from_value then looks fields up by schema name, so multi-word fields were silently dropped. Generated input classes now define _graphql_field_names(), and the converter unstructures Input subclasses with those names as renames.

Each SDK's core client is regenerated with its generator.

Not affected (checked on main)

  • Go: struct tags carry the schema name (json:"callId,omitempty"), and github.com/dagger/querybuilder marshals by json tag.
  • TypeScript: input types are emitted with schema names (callId?: string) and serialized by key.
  • PHP: input properties are named after schema fields ($callId), and AbstractInputObject::__toString serializes by property name.
  • Java: the generated toMap() uses the schema name as the key.
  • .NET: the generated ToKeyValuePairs() uses the schema name as the key.

Tests

Unit tests build each query without an engine and check the schema field names:

  • Rust: input_object_fields_use_schema_names (dagger-sdk lib.rs), with LLMMessageOriginInput.
  • Elixir: QueryBuilderTest "encode input object with schema field names".
  • Python: test_input_object_field_names checks the unstructured args and the printed DSL against a small schema. It failed on main with {'agent_name': ..., 'reply_to': ...}. A codegen test covers the generated _graphql_field_names().

Passing locally: rust-client/test, rust-client/cargo-fmt, elixir-client/sdk-test, elixir-client/codegen-test, elixir-client/lint, python-client/python-310/unit, python-client/python-314/unit, python-client/lint. I also ran python-client/python-312/unit before the fix, and the new Python test failed there as expected. I didn't run the integration tests locally; CI runs them.

@vito
vito requested review from a team as code owners October 10, 2026 20:04
vito added 3 commits October 20, 2026 22:12
Input structs use snake_case Rust fields (call_id, agent_name), and
serde_graphql_input serialized those identifiers verbatim, so the engine
received e.g. `call_id` instead of `callId`. The generator now emits
`#[serde(rename = "<schemaName>")]` on every input field.

Signed-off-by: Alex Suraci <[email protected]>
The query builder encoded input structs with their snake_case keys, so
e.g. LLMMessageOriginInput sent `agent_name`/`reply_to`. Generated input
modules now define `__field_names__/0`, mapping each key to its schema
field name, and the query builder uses it when encoding structs.

Unset (nil) input fields were also encoded as an empty value (`ref:`),
which is invalid GraphQL; they are now sent as `null`.

Signed-off-by: Alex Suraci <[email protected]>
Input dataclasses have snake_case attributes (call_id, mime_type) and
cattrs unstructured them by attribute name. graphql-core's ast_from_value
then looks fields up by schema name, so multi-word fields were silently
dropped from the query.

Generated input classes now define `_graphql_field_names()`, and the
converter unstructures Input subclasses with those names as renames.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the fix-input-field-names branch from ac31c16 to b4bb4c9 Compare October 21, 2026 02:12
@vito
vito force-pushed the fix-input-field-names branch from b4bb4c9 to b7fcb1b Compare November 6, 2026 19:24
@vito
vito merged commit cfe18a8 into dagger:main Nov 23, 2026
95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants