I am running into an error when trying to get an argument from a mutation
```namespace Performance.GraphQl
{
public class PerformanceMutation :ObjectGraphType
}
The PerformanceSession Object by my company's design needs a constructor that takes a Core object
namespace Performance.Data
{
public class PerformanceSession : ModelBase
{
public PerformanceSession(Core core) : base(core)
{
}
public override IModelPersistenceBase GetPersistence()
{
return new PerformanceSessionPersistence(UlineCore);
}
///OTHER LOGIC///
}
Is having a DI dependent class in the context.GetArguments<T> method not supported?
Here is my Schmea in case that is needed to help, but I pretty much copied from the StarWars example.
namespace Performance.GraphQl
{
public class PerformanceSchema : Schema
{
public PerformanceSchema(IDependencyResolver resolver): base(resolver)
{
Query = resolver.Resolve
Mutation = resolver.Resolve
}
}
}
```
And the Resolver
```namespace Performance
{
public class UnityResolver : IDependencyResolver
{
protected IUnityContainer container;
public UnityResolver(IUnityContainer container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
this.container = container;
}
public object GetService(Type serviceType)
{
try
{
return container.Resolve(serviceType);
}
catch (ResolutionFailedException)
{
return null;
}
}
public IEnumerable<object> GetServices(Type serviceType)
{
try
{
return container.ResolveAll(serviceType);
}
catch (ResolutionFailedException)
{
return new List<object>();
}
}
public IDependencyScope BeginScope()
{
var child = container.CreateChildContainer();
return new UnityResolver(child);
}
public void Dispose()
{
Dispose(true);
}
protected virtual void Dispose(bool disposing)
{
container.Dispose();
}
}
}```
Thanks for any help you can provide
Arguments are not setup to support DI. They are designed to use basic DTOs. So you would need to create a DTO with a parameterless constructor that represents your arguments.
Thats what I suspected, but thanks for the confirmation.
Argument are just a Dictionary<string, object>, so you could write your own mapper if you really like, though having a DTO is a bit easier.
Most helpful comment
Argument are just a
Dictionary<string, object>, so you could write your own mapper if you really like, though having a DTO is a bit easier.