Skip to content

[Bug]: GraphQL fields listed after a fragment spread are silently dropped #3861

Open

Description

Note: The below was written and discovered by claude but I have independently verified it myself as well.

What happened?

When a selection set contains a fragment spread (or inline fragment), every field listed after it in the same selection set is never added to the SQL query. Those fields come back null with no error. This applies to both scalar fields and relationship fields.

Repro:

query {
  book_by_pk(id: 1) {
    ...bookFields
    title
    publishers { name }
  }
}

fragment bookFields on book { id }

Expected: id, title and publishers are populated.
Actual: id is populated; title and publishers are null.

The same query works if ...bookFields is moved to the end of the selection set, or removed.

Cause: in SqlQueryStructure.AddGraphQLFields, both the FragmentSpread and the InlineFragment branches recurse into the fragment and then return;. That exits the foreach over the remaining selections. These look like they should be continue;:

https://github.com/Azure/data-api-builder/blob/main/src/Core/Resolvers/Sql%20Query%20Structures/SqlQueryStructure.cs (the two return; statements after the recursive AddGraphQLFields calls)

The return; dates from #1236, which added fragment support for #1235. The Cosmos path (GenerateQueryColumns) iterates over every selection and isn't affected.

Version

2.1.5

What database are you using?

Azure SQL

What hosting model are you using?

Container Apps

Which API approach are you accessing DAB through?

GraphQL

Relevant log output


Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageissues to be triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions