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

162
Vistas
GraphQL: "El campo \"updateOwner\" del tipo \"¡Propietario!\" debe tener una selección de subcampos. ¿Quiso decir \"updateOwner { ... }\"?"

Estoy tratando de obtener una consulta de actualización de mutación en GraphQL Playground. Soy nivel básico en GraphQL y en fase de aprendizaje. No sé cómo crear una mutación actualizada para el siguiente código de propietario. ¿Alguna idea de lo que me falta en mi código/consulta?

---Resolutor---

 > @Mutation(() => Owner) updateOwner( > @Args('id', { type: () => Int }) id: number, > @Args('updateOwnerInput') updateOwnerInput: UpdateOwnerInput) { > return this.ownersService.update(id, updateOwnerInput); }

---Servicio---

 update(id: number, updateOwnerInput: UpdateOwnerInput) { return this.ownersRepository.update(id, updateOwnerInput); }

---dto---

 @InputType() export class UpdateOwnerInput extends PartialType(CreateOwnerInput) { @Column() @Field(() => Int) id: number; }

---entidad---

 @Entity() @ObjectType() export class Owner { @PrimaryGeneratedColumn() @Field(type => Int) id: number; @Column() @Field() name: string; @OneToMany(() => Pet, pet => pet.owner) @Field(type => [Pet], { nullable: true }) pets?: Pet[]; }

---esquema---

 type Pet { id: Int! name: String! type: String ownerId: Int! owner: Owner! } type Owner { id: Int! name: String! pets: [Pet!] } type Query { getPet(id: Int!): Pet! pets: [Pet!]! owners: [Owner!]! owner(id: Int!): Owner! } type Mutation { createPet(createPetInput: CreatePetInput!): Pet! createOwner(createOwnerInput: CreateOwnerInput!): Owner! updateOwner(id: Int!, updateOwnerInput: UpdateOwnerInput!): Owner! } input CreatePetInput { name: String! type: String ownerId: Int! } input CreateOwnerInput { name: String! } input UpdateOwnerInput { name: String id: Int! }

---Consulta GraphQL (no sé si es correcta o incorrecta)

 mutation { updateOwner (updateOwnerInput:{ id:6, name: "josh", }) }

---error---

 "message": "Field \"updateOwner\" of type \"Owner!\" must have a selection of subfields. Did you mean \"updateOwner { ... }\"?",
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Debe hacer una selección de subcampos para devolver (incluso si no está interesado en ninguno):

 mutation { updateOwner (updateOwnerInput:{ id:6, name: "josh", }) { id name } }
about 4 years ago · Juan Pablo Isaza Denunciar
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