我试着让graphql在我的rails应用程序上工作。到目前为止,我已经或多或少地设置了所有东西,但是当我进入浏览器中的/graphiql页面时,我无法访问我的自定义UserType (不过,预定义的测试用例以前已经开始工作了。我在developer : NoMethodError in GraphqlController#execute未定义方法‘`UserType’的网络选项卡中获得了以下错误消息:# GraphQL::Define::TypeDefiner:0x007fa3728b2348
你能帮帮我吗?
我的模式定义如下:(leaves_messenger_schema.rb)
LeavesMessengerSchema = GraphQL::Schema.define do
mutation(Types::MutationType)
query(Types::QueryType)
end我的UserType定义如下:(type/user_type. as )
Types::QueryType = GraphQL::ObjectType.define do
name "Query"
field :viewer, types.UserType do
resolve ->(obj, args, ctx) {
ctx[User.last]
}
end
end和我的UserType (type/user_type. my ):
Types::UserType = GraphQL::ObjectType.define do
name 'User'
description 'A user'
field :id, types.String
field :email, types.String
end我的routes.rb被定义为每个生成器。这应该是正确的,因为我可以导航到graphiql页面,并且测试用例生效了。
非常感谢你给我的任何建议!
发布于 2017-10-15 14:17:15
我想你做了一个错误,试着改变你的代码
field :viewer, types.UserType do到field :viewer, Types::UserType do
https://stackoverflow.com/questions/46755660
复制相似问题