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

747
Views
El nombre `Foo` ya estaba registrado por otro tipo, GraphQL

Estoy usando GraphQL como parte de mi aplicación CQRS. He separado el modelo de dominio Command y Query en dos proyectos diferentes (Query y Command). cada uno de sus proyectos tiene algunos modelos, por ejemplo, el modelo Student. Uso dos modelos diferentes en Domain.Query.Students.Student y Domain.Command.Students.Student , pero ambos tienen el mismo nombre de entidad (Estudiante y Dirección). Simplifiqué mi entidad de la siguiente manera:

 public class Student:Entity { public string FirstName { get; set; } public string LastName { get; set; } public Address Address { get; set; } public DateTimeOffset CreatedOn { get; set; } public DateTimeOffset ModifiedOn { get; set; } }

El estudiante se está utilizando en proyectos de Consulta y Comando. en Startup.cs he configurado GraphQL así:

 services .AddGraphQLServer() .AddQueryType<StudentQuery>() .AddMutationType<AddStudentMutation>();

En StudentQuery.cs

 namespace GraphQL.Query.Students { public class StudentQuery { public List<Student> AllStudents([ScopedService] StudentRepository studentRepository) { var query = studentRepository.GetEmployees(); return query; } } }

y AddStudentMutation.cs

 namespace GraphQL.Command.Students { public class AddStudentMutation { public async Task<Student> AddStudentAsync(AddStudentInputType student,[Service] IMediator mediator) { var result =await mediator.Send(new AddStudentCommand(student.FirstName,student.LastName,student.StreetAddress, student.City,student.State,student.ZipCode)); return result; } } [GraphQLName("AddStudentInput")] public class AddStudentInputType { public string FirstName { get; set; } public string LastName { get; set; } public string StreetAddress { get; set; } public string City { get; set; } public string State { get; set; } public string ZipCode { get; set; } } }

Cuando ejecuto la aplicación me sale el siguiente error:

 The name `Student` was already registered by another type. (HotChocolate.Types.ObjectType<Domain.Query.Students.Student>)

Si cambio la entidad Student en Domain.Query.Students.Student a ReadStudent o algo más, se ejecutará sin ningún problema, pero no quiero cambiarlo.

over 4 years ago · Santiago Trujillo
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!