I'm trying to create class with enum and I have an error.
public class MarsWheather {
public Season MarsSeason { get; set; }
}
public enum Season {
winter,
spring,
summer,
autumn
}
My graphql classes look like:
public class SolSchema : Schema
{
public SolSchema(IServiceProvider sp) : base(sp)
{
Query = sp.GetRequiredService<SolDataQuery>();
Mutation = sp.GetRequiredService<SolDataMutation>();
}
}
public class SolDataQuery : ObjectGraphType<object>
{
public SolDataQuery(INasaProvider nasaProvider)
{
Field<MarsWheatherType>("wheather", resolve: context => nasaProvider.GetAsync());
}
}
public class MarsWheatherType : ObjectGraphType<MarsWheather>
{
public MarsWheatherType()
{
Field(w => w.MarsSeason);
}
}
public class SeasonEnum : EnumerationGraphType<Season>
{ }
I've registered it in startup.cs (ConfigureServices method) :
services.AddSingleton<SolDataQuery>();
services.AddSingleton<SolDataMutation>();
services.AddSingleton<SeasonEnum>();
services.AddSingleton<MarsWheatherType>();
services.AddSingleton<ISchema, SolSchema>();
I'm useing GraphQLPlayground. My request is :
wheather { marsSeason}
After all of it I have an error:
GraphQL.Execution.UnhandledError: Error executing document.\r\n ---> >System.InvalidOperationException: Required service for type >GraphQL.Types.EnumerationGraphType`1[Mars.Season] not found\r\n at >GraphQL.Utilities.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type >serviceType) in /_/src/GraphQL/Utilities/ServiceProviderExtensions.cs:line 42
This error has code "INVALID_OPERATION"
Could somebody help me please? What do I do wrong? P.S. If it help, I pushed this not finished project on github