Skip to content
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

Support multiple content types in details fields #3067

Open
wants to merge 2 commits into
base: flatten-graphql-edition
Choose a base branch
from

Conversation

brucebolt
Copy link
Member

@brucebolt brucebolt commented Jan 2, 2025

According to ADR-004, it is possible to represent content in an array format containing multiple types. This can include already parsed govspeak in HTML format or only govspeak. In the latter case, Publishing API parses this and converts to HTML before sending the content to Content Store.

This replicates that behaviour for GraphQL responses, expanding this to all fields within details, not just the body.

As we are now using the DetailsPresenter, it also has the side effect of supporting embedded content and full change history in GraphQL responses.

Trello card

@brucebolt brucebolt force-pushed the support-govspeak-graphql branch 2 times, most recently from 4cde8c1 to 81db2c2 Compare January 2, 2025 11:16
@brucebolt brucebolt changed the title Properly support multiple content types in details fields Support multiple content types in details fields Jan 2, 2025
@brucebolt brucebolt force-pushed the support-govspeak-graphql branch 4 times, most recently from 16d377f to 5302262 Compare January 2, 2025 14:54
@brucebolt brucebolt marked this pull request as ready for review January 2, 2025 14:54
@brucebolt brucebolt force-pushed the flatten-graphql-edition branch from 213b539 to e3b484b Compare January 2, 2025 15:52
@brucebolt brucebolt force-pushed the support-govspeak-graphql branch from 5302262 to 82b93bd Compare January 2, 2025 16:00
This has been copied from Content Store [1] as it will be required to
select the HTML content from mixed content type fields in GraphQL
responses (e.g. where a document's `body` contains both govspeak and
HTML representations).

1: https://github.com/alphagov/content-store/blob/5d3654322f94d21e69570b8364372387d117808b/app/presenters/content_type_resolver.rb#L1
According to ADR-004, it is possible to represent content in an array
format containing multiple types. This can include already parsed
govspeak in HTML format or only govspeak. In the latter case, Publishing
API parses this and converts to HTML before sending the content to
Content Store.

This replicates that behaviour for GraphQL responses, expanding this to
all fields within `details`, not just the body (e.g. the
`more_information` and `need_to_know` fields, which use the Content
Schema defition `body_html_and_govspeak`)..

It also has the side effect of supporting embedded content and full
change history in GraphQL responses.
@brucebolt brucebolt force-pushed the support-govspeak-graphql branch from 82b93bd to 95045d5 Compare January 2, 2025 16:00
Copy link
Contributor

@mike3985 mike3985 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better than how I would've solved it 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants