{"action":"created","issue":{"url":"https://api.github.com/repos/nestjs/graphql/issues/77","repository_url":"https://api.github.com/repos/nestjs/graphql","labels_url":"https://api.github.com/repos/nestjs/graphql/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/nestjs/graphql/issues/77/comments","events_url":"https://api.github.com/repos/nestjs/graphql/issues/77/events","html_url":"https://github.com/nestjs/graphql/issues/77","id":364248222,"node_id":"MDU6SXNzdWUzNjQyNDgyMjI=","number":77,"title":"Entity decorators?","user":{"login":"caseyduquettesc","id":16676170,"node_id":"MDQ6VXNlcjE2Njc2MTcw","avatar_url":"https://avatars1.githubusercontent.com/u/16676170?v=4","gravatar_id":"","url":"https://api.github.com/users/caseyduquettesc","html_url":"https://github.com/caseyduquettesc","followers_url":"https://api.github.com/users/caseyduquettesc/followers","following_url":"https://api.github.com/users/caseyduquettesc/following{/other_user}","gists_url":"https://api.github.com/users/caseyduquettesc/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyduquettesc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyduquettesc/subscriptions","organizations_url":"https://api.github.com/users/caseyduquettesc/orgs","repos_url":"https://api.github.com/users/caseyduquettesc/repos","events_url":"https://api.github.com/users/caseyduquettesc/events{/privacy}","received_events_url":"https://api.github.com/users/caseyduquettesc/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-26T23:18:07Z","updated_at":"2018-10-19T17:22:18Z","closed_at":"2018-09-27T18:19:38Z","author_association":"NONE","body":"## I'm submitting a...\r\n<pre><code>\r\n[ ] Regression <!--(a behavior that used to work and stopped working in a new release)-->\r\n[ ] Bug report\r\n[x] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.\r\n</code></pre>\r\n\r\n## Current behavior\r\n<!-- Describe how the issue manifests. -->\r\nWhile the resolvers, queries, and mutations can be written in Typescript, the entities must be put in .gql files. For those of us also using TypeORM, it requires two definitions of the models.\r\n\r\n## Expected behavior\r\nSome of the features of [TypeGraphQL](https://github.com/19majkel94/type-graphql) look like they would fit in perfectly in this ecosystem. Much like the current autodiscovery of resolvers, I was hoping to have GQL entities autodiscovered using decorators.\r\n\r\n```ts\r\nimport { ObjectType, Field, Float } from 'type-graphql';\r\nimport { Entity, Column, OneToMany } from 'typeorm';\r\n\r\n@Entity()\r\n@ObjectType()\r\nclass Recipe {\r\n  @Field()\r\n  @Column()\r\n  title: string;\r\n\r\n  @Field({ nullable: true })\r\n  @Column({ nullable: true})\r\n  description?: string;\r\n\r\n  @Field(type => [Rate])\r\n  @OneToMany(() => Rate, rate => rate.recipe)\r\n  ratings: Rate[];\r\n\r\n  @Field(type => Float, { nullable: true })\r\n  @Column({ nullable: true })\r\n  get averageRating() {\r\n    const sum = this.ratings.reduce((a, b) => a + b, 0);\r\n    return sum / this.ratings.length;\r\n  }\r\n}\r\n```\r\nMaybe nestjs/graphql already works with type-graphql and I just haven't figured out how to do it. Was hoping for some compatibility or comparable features offered.\r\n\r\n## Minimal reproduction of the problem with instructions\r\n<!-- Please share a repo, a gist, or step-by-step instructions. -->\r\nAbove snippet good enough?\r\n\r\n## What is the motivation / use case for changing the behavior?\r\n<!-- Describe the motivation or the concrete use case. -->\r\nSingle source of truth for data models\r\n\r\n## Environment\r\n\r\n<pre><code>\r\nNest version: 5.3.10\r\n<!-- Check whether this is still an issue in the most recent Nest version -->\r\n \r\nFor Tooling issues:\r\n- Node version: 8.11\r\n- Platform:  Mac\r\n\r\nOthers:\r\n<!-- Anything else relevant?  Operating system version, IDE, package manager, ... -->\r\n@nestjs/graphql: 5.4.0\r\n@nestjs/typeorm: 5.2.2\r\n</code></pre>\r\n"},"comment":{"url":"https://api.github.com/repos/nestjs/graphql/issues/comments/431436144","html_url":"https://github.com/nestjs/graphql/issues/77#issuecomment-431436144","issue_url":"https://api.github.com/repos/nestjs/graphql/issues/77","id":431436144,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTQzNjE0NA==","user":{"login":"esistgut","id":869693,"node_id":"MDQ6VXNlcjg2OTY5Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/869693?v=4","gravatar_id":"","url":"https://api.github.com/users/esistgut","html_url":"https://github.com/esistgut","followers_url":"https://api.github.com/users/esistgut/followers","following_url":"https://api.github.com/users/esistgut/following{/other_user}","gists_url":"https://api.github.com/users/esistgut/gists{/gist_id}","starred_url":"https://api.github.com/users/esistgut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esistgut/subscriptions","organizations_url":"https://api.github.com/users/esistgut/orgs","repos_url":"https://api.github.com/users/esistgut/repos","events_url":"https://api.github.com/users/esistgut/events{/privacy}","received_events_url":"https://api.github.com/users/esistgut/received_events","type":"User","site_admin":false},"created_at":"2018-10-19T17:22:18Z","updated_at":"2018-10-19T17:22:18Z","author_association":"NONE","body":"Is there any update about this? Having multiple type definitions (typeorm entities, .graphql SDL files and auto generated typescript definitions from SDL) doesn't feel right."}}
{"actor":{"display_login":"esistgut"}}