wesleyyoung / perch-query-builder

Dynamically build TypeORM queries based on GraphQL queries for NestJS and TypeORM
GNU General Public License v3.0
45 stars 9 forks source link

Always select primary keys #13

Open Migushthe2nd opened 2 years ago

Migushthe2nd commented 2 years ago

Fixes #9

This PR makes it so that the primary columns are always selected. This will prevent joined relations from becoming null if no table column is selected

Migushthe2nd commented 2 years ago

This PR requires additional work in order to support for example __typename. Since it is not included in the tree.fields, the join (previews below) is added, but no field is selected. An example query would be

query {
  layout(id: "db") {
    previews {
      __typename
    }
  }
}
Migushthe2nd commented 2 years ago

Additional check was implemented. It will now check in the EntityMetadata if a field is a relation, instead of checking if field.fields.length > 0. This fixes __typename.