From f70ac933abf597bc60afb7dc594c0f5a7e2d9709 Mon Sep 17 00:00:00 2001 From: Christian Joudrey Date: Sun, 12 Feb 2017 17:09:22 -0500 Subject: [PATCH] Paginate fields on query root --- app/models/graph/types/query.rb | 36 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/app/models/graph/types/query.rb b/app/models/graph/types/query.rb index 3e4309e..4f40483 100644 --- a/app/models/graph/types/query.rb +++ b/app/models/graph/types/query.rb @@ -5,33 +5,45 @@ module Types description "The query root of this schema" field :person, Graph.find_by_id_field(Graph::Types::Person, ::Person) - field :allPeople, !types[!Person] do - resolve ->(_, _, _) { ::Person.all } + connection :allPeople, Person.connection_type do + resolve ->(_, _, _) { + ::Person.all + } end field :planet, Graph.find_by_id_field(Graph::Types::Planet, ::Planet) - field :allPlanets, !types[!Planet] do - resolve ->(_, _, _) { ::Planet.all } + connection :allPlanets, Planet.connection_type do + resolve ->(_, _, _) { + ::Planet.all + } end field :film, Graph.find_by_id_field(Graph::Types::Film, ::Film) - field :allFilms, !types[!Film] do - resolve ->(_, _, _) { ::Film.all } + connection :allFilms, Film.connection_type do + resolve ->(_, _, _) { + ::Film.all + } end field :species, Graph.find_by_id_field(Graph::Types::Species, ::Species) - field :allSpecies, !types[!Species] do - resolve ->(_, _, _) { ::Species.all } + connection :allSpecies, Species.connection_type do + resolve ->(_, _, _) { + ::Species.all + } end field :starship, Graph.find_by_id_field(Graph::Types::Starship, ::Starship) - field :allStarships, !types[!Starship] do - resolve ->(_, _, _) { ::Starship.all } + connection :allStarships, Starship.connection_type do + resolve ->(_, _, _) { + ::Starship.all + } end field :vehicle, Graph.find_by_id_field(Graph::Types::Vehicle, ::Vehicle) - field :allVehicles, !types[!Vehicle] do - resolve ->(_, _, _) { ::Vehicle.all } + connection :allVehicles, Vehicle.connection_type do + resolve ->(_, _, _) { + ::Vehicle.all + } end # Relay