通常,在 GraphQL/Rails 中,你有一个query_type.rb
看起来像这样的文件:
module Types
class QueryType < Types::BaseObject
# Add root-level fields here.
# They will be entry points for queries on your schema.
field :test_field, String, null: false do
description 'Test field'
end
def test_field
'My test field!'
end
end
end
我所有的查询都在这个文件中完全实现。有没有办法做类似的事情mutation_type.rb
并将查询实现范围扩展到其他文件?也许是这样的?:
查询类型.rb:
module Types
class QueryType < Types::BaseObject
# Add root-level fields here.
# They will be entry points for queries on your schema.
field :test_field, String, null: false, query: Types::TestFieldType
end
end
test_field_type.rb:
module Types
class TestFieldType < Types::BaseObject
description 'Test Field'
def test_field
'My Test field!'
end
end
end