Todo entity that is both an ORM entity, and part of a GQL schema definition
This file contains 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