Skip to content

Fix nodes returning empty when only __typename is requested#1170

Merged
myronmarston merged 2 commits intoblock:mainfrom
marcdaniels-toast:mdaniels/fix-typename-only-query-returns-no-nodes
May 9, 2026
Merged

Fix nodes returning empty when only __typename is requested#1170
myronmarston merged 2 commits intoblock:mainfrom
marcdaniels-toast:mdaniels/fix-typename-only-query-returns-no-nodes

Conversation

@marcdaniels-toast
Copy link
Copy Markdown
Contributor

When a query selects only __typename under nodes or edges { node }, requested_fields ends up empty (because __typename is a dynamic field and is stripped before populating requested_fields). This left individual_docs_needed: false, causing size: 0 in the datastore query and returning no documents despite total_edge_count > 0.

Fix by additionally setting individual_docs_needed: true whenever nodes or edges.node is selected at all — the client selecting that part of the query is itself the signal that individual documents are needed.

Fixes #1055

When a query selects only `__typename` under `nodes` or `edges { node }`,
`requested_fields` ends up empty (because `__typename` is a dynamic field
and is stripped before populating `requested_fields`). This left
`individual_docs_needed: false`, causing `size: 0` in the datastore query
and returning no documents despite `total_edge_count > 0`.

Fix by additionally setting `individual_docs_needed: true` whenever
`nodes` or `edges.node` is selected at all — the client selecting that
part of the query is itself the signal that individual documents are needed.

Fixes block#1055

Generated with Claude Code
Comment thread elasticgraph-graphql/spec/acceptance/search_spec.rb
…uested

Covers the fix from the previous commit at the unit level, as requested
in code review.

Generated with Claude Code
@myronmarston myronmarston enabled auto-merge (squash) May 9, 2026 02:35
@myronmarston myronmarston merged commit bbfaa36 into block:main May 9, 2026
19 checks passed
@marcdaniels-toast marcdaniels-toast deleted the mdaniels/fix-typename-only-query-returns-no-nodes branch May 9, 2026 03:20
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.

Querying an type for just nodes { __typename } returns no nodes when there are some

2 participants