Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Graphql querying many to many relationship

I have two entities Events and Profiles which have a many to many relationship. Im attempting to query an event with its associated profiles like so.

{
  event(id: 7){
    id
    username
    startDate
    endDate
    privacy
    timezone
    updatedAt
    createdAt
    creator{
      id
      username
    }
    profiles{
      Profile {
        id
        username
      }
    }
  }
}

But am getting ""message": "Cannot query field \"Profile\" on type \"Profile\"."," whenever i try to do so.

Event entity:

@ObjectType()
@Entity()
export class Event extends BaseEntity {
  @Field(() => Int)
  @PrimaryGeneratedColumn()
  id!: number

  @Field()
  @Column({ unique: true })
  username!: string

  @Field()
  @Column()
  title!: string

  @Field()
  @Column()
  description!: string

  @Field()
  @Column()
  privacy!: string

  @Field({ nullable: true, defaultValue: new Date() })
  @Column()
  startDate?: Date

  @Field({ nullable: true, defaultValue: new Date() })
  @Column()
  endDate?: Date

  @Field()
  @Column()
  timezone: string

  @Field()
  @Column()
  creatorId: number

  @Field(() => User)
  @ManyToOne(() => User, (user) => user.events)
  creator: User

  @Field(() => Profile)
  @ManyToMany(() => Profile, (profile) => profile.events)
  @JoinTable()
  profiles: Profile[]

  @Field(() => String)
  @UpdateDateColumn()
  updatedAt: Date

  @Field(() => String)
  @CreateDateColumn()
  createdAt: Date
}

Profile entity:

@ObjectType()
@Entity()
export class Profile extends BaseEntity {
  @Field(() => Int)
  @PrimaryGeneratedColumn()
  id!: number

  @Field()
  @Column({ unique: true })
  username!: string

  @OneToMany(() => Post, (post) => post.creator)
  posts: Post[]

  @OneToMany(() => Updoot, (updoot) => updoot.user)
  updoots: Updoot[]

  @ManyToMany(() => Event, (event) => event.profiles)
  events: Event[]

  @Field()
  @Column()
  userId: number

  @OneToOne(() => User, (user) => user.profile)
  user: User

  @Field(() => String)
  @UpdateDateColumn()
  updatedAt: Date

  @Field(() => String)
  @CreateDateColumn()
  createdAt: Date
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!