-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3872 from alphagov/graphql-ministers-index
Use GraphQL for rendering Ministers Index page
- Loading branch information
Showing
9 changed files
with
1,434 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Graphql::MinistersIndex | ||
attr_reader :content_item | ||
|
||
def initialize(content_item) | ||
@content_item = content_item | ||
end | ||
|
||
def self.find!(base_path) | ||
query = Graphql::MinistersIndexQuery.new(base_path).query | ||
|
||
edition = Services.publishing_api.graphql_query(query) | ||
.dig("data", "edition") | ||
.deep_transform_keys(&:underscore) | ||
|
||
new(edition) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
class Graphql::MinistersIndexQuery | ||
def initialize(base_path) | ||
@base_path = base_path | ||
end | ||
|
||
def query | ||
<<-QUERY | ||
{ | ||
edition(basePath: "#{@base_path}") { | ||
... on MinistersIndex { | ||
basePath | ||
links { | ||
orderedCabinetMinisters { | ||
...basePersonInfo | ||
} | ||
orderedAlsoAttendsCabinet { | ||
...basePersonInfo | ||
} | ||
orderedAssistantWhips { | ||
...basePersonInfo | ||
} | ||
orderedBaronessesAndLordsInWaitingWhips { | ||
...basePersonInfo | ||
} | ||
orderedHouseLordsWhips { | ||
...basePersonInfo | ||
} | ||
orderedHouseOfCommonsWhips { | ||
...basePersonInfo | ||
} | ||
orderedJuniorLordsOfTheTreasuryWhips { | ||
...basePersonInfo | ||
} | ||
orderedMinisterialDepartments { | ||
title | ||
webUrl | ||
details { | ||
brand | ||
logo { | ||
crest | ||
formattedTitle | ||
} | ||
} | ||
links { | ||
orderedMinisters { | ||
...basePersonInfo | ||
} | ||
orderedRoles { | ||
contentId | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
fragment basePersonInfo on MinistersIndexPerson { | ||
title | ||
basePath | ||
webUrl | ||
details { | ||
privyCounsellor | ||
image { | ||
url | ||
altText | ||
} | ||
} | ||
links { | ||
roleAppointments { | ||
details { | ||
current | ||
} | ||
links { | ||
role { | ||
contentId | ||
title | ||
webUrl | ||
details { | ||
rolePaymentType | ||
seniority | ||
whipOrganisation { | ||
label | ||
sortOrder | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
QUERY | ||
end | ||
end |
Oops, something went wrong.