I’m having some kind of a struggle.
I’m building an using the spacex api, i use the graphql endpoint to fetch my data: https://spacexdata.herokuapp.com/graphql
From there, the data is generated with graphql code generator and is strictly on the client side, it doesn’t interact with the server side where my user db is.
I have a user entity that looks like so:
import { Field, Int, ObjectType } from "type-graphql";
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
@Entity()
@ObjectType()
export class User extends BaseEntity {
@Field(() => Int)
@PrimaryGeneratedColumn()
id: number
@Field()
@Column({unique: true})
username: string
@Field()
@Column({unique: true})
email: string
@Column()
password: string
@Field(() => String, {nullable: true})
@Column({nullable: true})
avatar?: string
@Field(() => String, {nullable: true})
@Column({nullable: true})
first_name?: string
@Field(() => String, {nullable: true})
@Column({nullable: true})
last_name?: string
@Field(() => String)
@CreateDateColumn()
created_at: Date
@Field(() => String)
@UpdateDateColumn()
updated_at: Date
}
I’d like, when the user is logged in (i got that part covered aswell), to be able to bookmarks flight from the spacex api and i’m not sure how to proceed.
My questions are the following:
- Should I store the flight in a separate entity and do relationship with the user entity ?
- Should I create a new variable of type (Flight) that point to a separate class (that isn’t necessary an entity, just a model class) ?
- Should I store the bookmarks flight in the client side ?
Thank you !