vesper-framework/vesper

GraphQL schema subset query is selecting all fields in the model from the database

iamgmd opened this issue · 1 comments

Running any query using just a subset of schema fields is running queries on all fields in the model which ultimately kills performance.

{
  solution_all {
    solutionid
  }
}

is running this query.

SELECT "Solution"."configurationpageid" AS "Solution_configurationpageid", "Solution"."createdby" AS "Solution_createdby", "Solution"."createdon" AS "Solution_createdon", "Solution"."createdonbehalfby" AS "Solution_createdonbehalfby", "Solution"."description" AS "Solution_description", "Solution"."friendlyname" AS "Solution_friendlyname", "Solution"."installedon" AS "Solution_installedon", "Solution"."isinternal" AS "Solution_isinternal", "Solution"."ismanaged" AS "Solution_ismanaged", "Solution"."isvisible" AS "Solution_isvisible", "Solution"."modifiedby" AS "Solution_modifiedby", "Solution"."modifiedon" AS "Solution_modifiedon", "Solution"."modifiedonbehalfby" AS "Solution_modifiedonbehalfby", "Solution"."organizationid" AS "Solution_organizationid", "Solution"."parentsolutionid" AS "Solution_parentsolutionid", "Solution"."pinpointassetid" AS "Solution_pinpointassetid", "Solution"."pinpointsolutiondefaultlocale" AS "Solution_pinpointsolutiondefaultlocale", "Solution"."pinpointsolutionid" AS "Solution_pinpointsolutionid", "Solution"."publisherid" AS "Solution_publisherid", "Solution"."solutionid" AS "Solution_solutionid", "Solution"."solutionpackageversion" AS "Solution_solutionpackageversion", "Solution"."solutiontype" AS "Solution_solutiontype", "Solution"."uniquename" AS "Solution_uniquename", "Solution"."version" AS "Solution_version", "Solution"."versionnumber" AS "Solution_versionnumber" FROM "solutionbase" "Solution"

instead of.

SELECT "Solution"."solutionid" AS "Solution_solutionid" FROM "solutionbase" "Solution"

Is there a way to make this happen? I haven't even touched on relationships yet but I am assuming that it will be the same outcome.

`import graphqlFields = require('graphql-fields');

@query()
posts(args,context,info: GraphQLResolveInfo) {
// I want to select only title in this.
const select=Object.keys( graphqlFields(info) );
return this.entityManager.find("Post",{select});
}`