Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
iamgmd opened this issue Jun 3, 2018 · 1 comment

Comments

@iamgmd
Copy link

iamgmd commented Jun 3, 2018

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.

@lllyyylll2
Copy link

`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});
}`

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

No branches or pull requests

2 participants