Simplify the way QueryTypeCreator is used

This commit is contained in:
Alberto Miedes Garcés
2017-01-27 12:54:33 +01:00
parent 073ce38a8d
commit 620c83fb69
4 changed files with 10 additions and 23 deletions

View File

@@ -7,19 +7,16 @@ describe GraphQL::QueryTypeCreator do
Proposal => { fields: { id: :integer, title: :string } }
}
end
let(:api_types_creator) { GraphQL::ApiTypesCreator.new(api_type_definitions) }
let(:created_api_types) { api_types_creator.create }
let(:query_type_creator) { GraphQL::QueryTypeCreator.new(created_api_types) }
let(:api_types) { GraphQL::ApiTypesCreator.new(api_type_definitions).create }
describe "::create" do
let(:query_type) { query_type_creator.create }
let(:query_type) { GraphQL::QueryTypeCreator.create(api_types) }
it 'creates a QueryType with fields to retrieve single objects whose model fields included an ID' do
field = query_type.fields['proposal']
proposal_type = query_type_creator.created_api_types[Proposal]
expect(field).to be_a(GraphQL::Field)
expect(field.type).to eq(proposal_type)
expect(field.type).to eq(api_types[Proposal])
expect(field.name).to eq('proposal')
end
@@ -29,10 +26,9 @@ describe GraphQL::QueryTypeCreator do
it "creates a QueryType with connections to retrieve collections of objects" do
connection = query_type.fields['proposals']
proposal_type = query_type_creator.created_api_types[Proposal]
expect(connection).to be_a(GraphQL::Field)
expect(connection.type).to eq(proposal_type.connection_type)
expect(connection.type).to eq(api_types[Proposal].connection_type)
expect(connection.name).to eq('proposals')
end
end