Created
          February 1, 2023 16:36 
        
      - 
      
- 
        Save riivanov/62aca7e133d71cd24712c0c18b099fd1 to your computer and use it in GitHub Desktop. 
    Todo entity that is both an ORM entity, and part of a GQL schema definition
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { Field, ID, InputType, ObjectType } from "type-graphql"; | |
| import { Column, Entity, PrimaryGeneratedColumn } from "typeorm"; | |
| @ObjectType() | |
| @Entity() | |
| export class Todo { | |
| @Field() | |
| @PrimaryGeneratedColumn() | |
| id: number; | |
| @Field() | |
| @Column() | |
| task: string; | |
| } | |
| export type ITodo = { [K in keyof Todo]: Todo[K] }; | |
| @InputType() | |
| export class TodoInput implements Partial<Todo> { | |
| @Field({ nullable: true }) | |
| id: number; | |
| @Field() | |
| task: string; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment