Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda