revision_of_build_id is referencing builds.id . The actual data coming back correctly has all build columns on the row + a revision key which correctly shows a single build row. The problem is that the TS type for data thinks that the value of the revision key is an array of builds rather than a single row object. I would be fine with revision actually returning an array of 1 to match the type, the tough part is that it's returning an object .