Select only limited query params
Closed this issue · 1 comments
0xHexE commented
I'm trying to write the query
query {
posts(limit: 0, offset: 1) {
title
}
}
But in the sql it is executing like
SELECT "Post"."id" AS "Post_id", "Post"."title" AS "Post_title", "Post"."text" AS "Post_text" FROM "post";
I want to select the title but it also select the other query too.
How can I get the title
in the controller.
@Query()
posts() {
// I want to select only title in this.
return this.entityManager.find();
}
lllyyylll2 commented
The 3th parameter contains the select fields info which is not described in vesper document.
`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});
}`