hasura/graphql-engine · error
no fields are selected
Error message
no fields are selected
What it means
Error returned by normalize_selection_sets (selection_set.rs:141) when a selection set for a field or operation contains no actual field selections — for example a set consisting only of fragments that resolve to nothing, or `field { }` with an empty braces block. GraphQL requires at least one field in every selection set.
Source
Thrown at v3/crates/graphql/lang-graphql/src/validation/error.rs:186
argument_name: ast::Name,
},
#[error(
"argument {argument_name} on field {field_name} of type {type_name} is defined more than once"
)]
DuplicateArguments {
type_name: ast::TypeName,
field_name: ast::Name,
argument_name: ast::Name,
},
#[error(
"required argument {argument_name} not found on field {field_name} of type {type_name}"
)]
RequiredArgumentNotFound {
type_name: ast::TypeName,
field_name: ast::Name,
argument_name: ast::Name,
},
#[error("no fields are selected")]
FieldSelectionSetIsEmpty,
}
View on GitHub (pinned to 724551b9ae)
Solutions
- Add at least one concrete subfield inside the empty `{ }` block
- If building queries programmatically, skip emitting the field entirely when the subfield list is empty
- Ensure fragments referenced in the set actually apply to the parent type
Example fix
# before
query { user { posts { } } }
# after
query { user { posts { id } } } Defensive patterns
Strategy: validation
Validate before calling
// When building selections programmatically, require at least one subfield
fn build_field(name: &str, subs: &[Field]) -> String {
assert!(!subs.is_empty(), "selection set must not be empty");
format!("{name} {{ {} }}", subs.iter().map(to_string).collect::<Vec<_>>().join(" "))
} Try / catch
// Catch Error::FieldSelectionSetIsEmpty during normalize_selection_sets and reject the generated query before execution
Prevention
- Never emit `{ }` blocks from query builders
- Lint generated queries for empty selection sets
When it happens
Trigger: A query or nested field with an empty selection set `{ }`, or a selection set whose fragments/__typename-only content normalizes to zero fields, hits `Err(Error::FieldSelectionSetIsEmpty)` during normalize_selection_sets.
Common situations: Programmatic query construction that emits empty braces when a list of subfields is empty, templates with optional subselections, or fragments that don't match the type and get filtered out.
Related errors
- a selection set is specified on field '{field_name}' of non-
- validation failed: {0}
- Unexpected value: expecting {expected_kind:}, but found: {fo
- '{name:}' is not a valid GraphQL name.
- '{alias:} is not a valid alias
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/cc6b49874b72ad95.
Report an issue: GitHub.