-
Notifications
You must be signed in to change notification settings - Fork 16
[PP-7275] Spike into automating the creation of GraphQL queries #3474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
brucebolt
wants to merge
6
commits into
main
Choose a base branch
from
graphql-content-store
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
218e9f3
Add Content Store-like API endpoint for GraphQL
brucebolt d74d779
Add `GraphqlQueryBuilder` from `govuk-graphql`
brucebolt 7f40f2b
Update `GraphqlQueryBuilder` to match this app
brucebolt fa15577
Add GraphQL query for schema `hmrc_manual`
brucebolt 157454c
Add GraphQL query for schema `topical_event`
brucebolt 348f2a7
Loop through schemas and output the query class as a file
brucebolt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
15 changes: 15 additions & 0 deletions
15
app/queries/graphql/fragments/_available_translations.graphql.erb
This file contains hidden or 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,15 @@ | ||
| fragment AvailableTranslations on Links { | ||
| available_translations { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| document_type | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions
48
app/queries/graphql/fragments/_child_and_parent_taxons.graphql.erb
This file contains hidden or 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,48 @@ | ||
| fragment Taxon on Edition { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| description | ||
| details { | ||
| internal_name | ||
| notes_for_editors | ||
| visible_to_departmental_editors | ||
| } | ||
| document_type | ||
| locale | ||
| phase | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
|
|
||
| <%# The deepest nodes in GOV.UK's taxonomy are 5 levels deep (i.e. the root, plus 4 child taxons) %> | ||
| <%# For example https://www.gov.uk/api/content/transport/hs2-phase-2b %> | ||
| <%# We don't expand the whole taxonomy when looking at the root, so we only need the 4 levels. %> | ||
| <%# The first level expands the backlink to parent, but lower levels do not. %> | ||
| fragment ChildAndParentTaxons on Links { | ||
| child_taxons: links_of_type(type: parent_taxons, reverse: true) { | ||
| ...Taxon | ||
| links { | ||
| child_taxons: links_of_type(type: parent_taxons, reverse: true) { | ||
| ...Taxon | ||
| links { | ||
| child_taxons: links_of_type(type: parent_taxons, reverse: true) { | ||
| ...Taxon | ||
| links { | ||
| child_taxons: links_of_type(type: parent_taxons, reverse: true) { | ||
| ...Taxon | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| parent_taxons: links_of_type(type: parent_taxons) { | ||
| ...Taxon | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,39 @@ | ||
| <%# TODO: this is used in ~10 places, but they all have different kinds of children so it's not really reusable %> | ||
| fragment Children on Links { | ||
| children: links_of_type(type: parent, reverse: true) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| document_type | ||
| details { | ||
| access_and_opening_times | ||
| } | ||
| links { | ||
| <%# | ||
| The back link to parent is here for compatibility with current link-expansion behaviour, | ||
| but I'm reasonably sure it's accidental and unnecessary. Why would you want to link from | ||
| a document to its child, and then back up to the parent? | ||
| %> | ||
| parent: links_of_type(type: parent) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| document_type | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } |
This file contains hidden or 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,15 @@ | ||
| fragment ContentOwners on Links { | ||
| content_owners: links_of_type(type: content_owners) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| document_type | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
app/queries/graphql/fragments/_default_top_level_fields.graphql.erb
This file contains hidden or 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,19 @@ | ||
| fragment DefaultTopLevelFields on Edition { | ||
| analytics_identifier | ||
| base_path | ||
| content_id | ||
| description | ||
| document_type | ||
| first_published_at | ||
| locale | ||
| phase | ||
| public_updated_at | ||
| publishing_app | ||
| publishing_request_id | ||
| publishing_scheduled_at | ||
| rendering_app | ||
| scheduled_publishing_delay_seconds | ||
| schema_name | ||
| title | ||
| updated_at | ||
| } |
37 changes: 37 additions & 0 deletions
37
app/queries/graphql/fragments/_document_collections.graphql.erb
This file contains hidden or 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,37 @@ | ||
| fragment DocumentCollections on Links { | ||
| document_collections: links_of_type(type: documents, reverse: true) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| document_type | ||
| <%# | ||
| Getting all of the documents in a collection would sometimes be prohibitively expensive. | ||
| Current link expansion behaviour special cases this so that only the grandparent document | ||
| is expanded. Nobody's quite sure why this behaviour is desirable though, so I'm not going | ||
| to reimplement it until we know why it's needed. | ||
|
|
||
| links { | ||
| documents: links_of_type(type: documents) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| document_type | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } | ||
| %> | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| fragment Government on Links { | ||
| government: links_of_type(type: government) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| details { | ||
| current | ||
| ended_on | ||
| started_on | ||
| } | ||
| document_type | ||
| locale | ||
| title | ||
| web_url | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
app/queries/graphql/fragments/_level_one_taxons.graphql.erb
This file contains hidden or 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,37 @@ | ||
| fragment LevelOneTaxons on Links { | ||
| level_one_taxons: links_of_type(type: root_taxon, reverse: true) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| description | ||
| details { | ||
| internal_name | ||
| notes_for_editors | ||
| visible_to_departmental_editors | ||
| } | ||
| document_type | ||
| links { | ||
| root_taxon: links_of_type(type: root_taxon) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| document_type | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } | ||
| locale | ||
| phase | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
app/queries/graphql/fragments/_mainstream_browse_pages.graphql.erb
This file contains hidden or 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,16 @@ | ||
| fragment MainstreamBrowsePages on Links { | ||
| mainstream_browse_pages: links_of_type(type: mainstream_browse_pages) { | ||
| api_path | ||
| api_url | ||
| base_path | ||
| content_id | ||
| description | ||
| document_type | ||
| locale | ||
| public_updated_at | ||
| schema_name | ||
| title | ||
| web_url | ||
| withdrawn | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / Brakeman
Unsafe reflection method constantize called on model attribute. Warning