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

745
Views
The name `Foo` was already registered by another type, GraphQL

I am using GraphQL as a part of my CQRS application. I have separated Command and Query domain model into two different projects (Query and Command). each of there projects has some models for instance Student model. I use two different model in Domain.Query.Students.Student and Domain.Command.Students.Student, but both have the same entity name (Student and Address) I simplified my entity as below:

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; }
 }

Student is being used in Query and Command projects. in Startup.cs I have configured GraphQL like this:

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

In StudentQuery.cs

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

and 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; }
    }
}

When I run the application I get the following error:

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

If I change the Student entity in Domain.Query.Students.Student to ReadStudent or something else, it will run without any issue, but I don't want to change it.

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!