Hi,
I'm trying to use a generic response using ObjectGraphType like this:
public class ResponseRegister
{
public ResponseRegister(){
Field(x => x.Error, nullable:true).Description("Hay error");
Field
.Description("Lista de errores")
.Name("ErrorList");
Field
.Name("Entity")
.Description("Entity");
}
}
When I register each mutations like this:
Field
(
"CreateSchoolSite",
arguments:new QueryArguments(new QueryArgument
resolve: context =>
{
var entity = context.GetArgument
return _repository.AddSchoolSiteAsync(entity);
}
);
Field
(
"CreateTeacher",
arguments:new QueryArguments(new QueryArgument
resolve: context =>
{
var entity = context.GetArgument
return _repository.AddTeacherAsync(entity);
}
);
It alwasy takes the last field register to autocomplete on graphiQL, I'd like to know if that's a problem with something that I'm doing, with the component or maybe with GraphiQL. For example in this case, if I try to call the mutation CreateSchoolSite, it takes the values of CreateTeacher to autocomplete the response.
Thanks for your help
Are you providing a unique type name on your ResponseRegister types?
Hi @joemcbride
What do you mean on "unique type name"?
My ResponseRegister is like this:
public class ResponseRegister
{
public ResponseRegister(){
Field(x => x.Error, nullable:true).Description("Hay error");
Field
.Description("Lista de errores")
.Name("ErrorList");
Field
.Name("Entity")
.Description("Entity");
}
}
And in the implementations, I'm trying to do it in this way
Field
Field
If I try to call the mutation the autocomplete always shows me
the option of the TeacherType for the response of the migration, in this way
mutation{
createSchool
(
school:
{
name:"test school same ID"
internalIdentification:"800236529"
}
) {
entity{
userId
}
}
}
But the parameter userId doesn't belongs to StudentType, it belongs to TeacherType.
Hi @joemcbride
Now I got what you meant. The issue was caused because I didn't add a unique name for the generic ObjectGraphType. It was solved just by doing this:
public class ResponseRegister
{
public ResponseRegister(){
Name=typeof(TEntity).Name;
Field(x => x.Error, nullable:true).Description("Hay error");
Field
.Description("Lista de errores")
.Name("ErrorList");
Field
.Name("Entity")
.Description("Entity");
}
}
Thanks
Most helpful comment
Are you providing a unique type name on your ResponseRegister types?