-
Notifications
You must be signed in to change notification settings - Fork 119
Open
Description
Current build does not allow you to create an entity and then with another mutation delete that entity.
Steps to reproduce:
- Create Add Mutation
- Create Delete Mutation
- Add item
mutation ($day: DayInput!) {
createDay(day:$day){
id
agendaDay
}
}
mutation ($day: DayInput!) {
createDay(day:$day){
id
agendaDay
}
}
- Immediately try and delete
mutation ($dayId: Int!) {
deleteDay(dayId:$dayId){
id
agendaDay
}
}
{
"dayId" : "7004"
}
I get the following error
{
"data": {
"deleteDay": null
},
"errors": [
{
"message": "There was an error deleting 7004: The instance of entity type 'Day' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"deleteDay"
]
}
]
}
I believe this line is the reason
var sp = services.BuildServiceProvider();
services.AddSingleton<ISchema>(new MITSSchema(new FuncDependencyResolver(type =>sp.GetService(type))));I replaced it with below and it works as expected.
services.AddScoped<IDependencyResolver>(s => new FuncDependencyResolver(s.GetRequiredService));Metadata
Metadata
Assignees
Labels
No labels