如何解决GraphQL.Types.EnumerationGraphType
我正在尝试使用枚举创建类,但出现错误。
public class MarsWheather {
public Season MaRSSeason { get; set; }
}
public enum Season {
winter,spring,summer,autumn
}
我的 graphql 类看起来像:
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>
{ }
我已经在 startup.cs(ConfigureServices 方法)中注册了它:
services.AddSingleton<SolDataQuery>();
services.AddSingleton<SolDataMutation>();
services.AddSingleton<SeasonEnum>();
services.AddSingleton<MarsWheatherType>();
services.AddSingleton<ISchema,SolSchema>();
我正在使用 GraphQLPlayground。我的要求是:
wheather {
maRSSeason}
GraphQL.Execution.UnhandledError:执行文档时出错。\r\n ---> >system.invalidOperationException:找不到类型 >GraphQL.Types.EnumerationGraphType`1[Mars.Season] 所需的服务\r\n >GraphQL.Utilities.ServiceProviderExtensions.GetrequiredService(IServiceProvider provider,Type >serviceType) in /_/src/GraphQL/Utilities/ServiceProviderExtensions.cs:line 42
有人可以帮我吗?我做错了什么? 附注如果有帮助,我将这个未完成的项目推送到 github
解决方法
好的。 MarsWheatherType 的正确代码是:
class Product < ApplicationRecord
has_one_attached :attachment
end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。