当向我的rails后端发出graphql API请求时,我在app/graphql/types/query_type.rb
中得到以下错误:
Started POST "/graphql" for 127.0.0.1 at 2023-04-06 13:27:07 +0200
Processing by GraphqlController#execute as */*
Parameters: {...}
Completed 500 Internal Server Error in 266ms (ActiveRecord: 0.0ms | Allocations: 3660)
NameError (uninitialized constant Types::BaseObject):
app/graphql/types/query_type.rb:2:in `<module:Types>'
app/graphql/types/query_type.rb:1:in `<main>'
...
这是QueryType类:
module Types
class QueryType < Types::BaseObject
field :discord_user, DiscordUserType, null: true do
argument :id, ID, required: true
end
def discord_user(id:)
DiscordUser.find(id)
end
field :discord_users, [DiscordUserType], null: false
def discord_users
DiscordUser.all
end
end
end
我自己没有发现命名约定的错误,因为BaseObject是由graphql
gem提供的,我不知道为什么会有错误。
1条答案
按热度按时间pinkon5k1#
你好像嵌套错了。
尝试