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

Add support for news articles to GraphQL endpoint #3008

Merged
merged 6 commits into from
Dec 9, 2024

Conversation

brucebolt
Copy link
Member

@brucebolt brucebolt commented Nov 28, 2024

This allows us to retrieve news articles using a GraphQL query.

Trello card

@brucebolt brucebolt force-pushed the graphql-news-articles branch 22 times, most recently from 4fdee73 to 82c4a18 Compare December 2, 2024 14:56
@brucebolt brucebolt marked this pull request as ready for review December 3, 2024 16:28
Copy link
Member

@yndajas yndajas left a comment

Choose a reason for hiding this comment

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

No real issues with the code itself here, but a few more thoughts/questions on the generic/specific debate that it would probably be good to discuss alongside the simplification PR when we mob

@@ -4,10 +4,11 @@ module Types
class QueryType < Types::BaseObject
field :edition, EditionTypeOrSubtype, description: "An edition or one of its subtypes" do
argument :base_path, String
argument :content_store, String, required: false, default_value: "live"
Copy link
Member

Choose a reason for hiding this comment

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

question: interface

  • Will content_store be the most obvious name for this argument for frontend devs/in client code (versus e.g. state or publishing_state)?
  • Do you know what the difference is between content_store, state, and phase (and why is content_store the correct one to use here?)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, we're gonna have to face this decision at some point! I wonder if there's already a Content Store-free name for this concept in use?

spec/graphql/types/query_type_spec.rb Outdated Show resolved Hide resolved
Comment on lines +4 to +11
class NewsArticleType < Types::EditionType
def self.document_types = %w[
government_response
news_story
press_release
world_news_story
]
end
Copy link
Member

Choose a reason for hiding this comment

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

thought: approach

Given the lack of type-specific fields, I'm curious if there's a benefit to this versus just falling back to the generic EditionType

Comment on lines 52 to 114
field :available_translations, [Translation]

def available_translations
Presenters::Queries::AvailableTranslations.by_edition(object)
.translations.fetch(:available_translations, [])
end
Copy link
Member

Choose a reason for hiding this comment

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

thought: genericness

Is this link type available/present on all editions/types? If not, I've wondered before about a mixin approach for shared links that aren't quite generic enough to appear everywhere (e.g. include AvailableTranslationsLinks in the relevant type classes). This feels related to the conversation over on the other PR!

Similar thoughts on the next commit - where/if to draw the line between generic and specific/how precise to be with our typing

spec/integration/graphql/news_article_spec.rb Outdated Show resolved Hide resolved
spec/integration/graphql/news_article_spec.rb Outdated Show resolved Hide resolved
At the moment, GraphQL queries only return the live edition of a
document.

This change allows users to request either the draft or live version of
the document.
We are implementing news articles, which have many document types.
Therefore we need to allow a GraphQL type to be found from multiple
document types.
This creates a news article type, which inherits from the Edition type.

There are no fields specific to this type, so everything can be
inherited from the generic edition.
This link is used by multiple types of edition, so we should move it to
the edition type, to reduce the need for duplicating the same in each
type.
These are used on most editions, so can exist in a shared space.
@mike3985 mike3985 force-pushed the graphql-news-articles branch from 82c4a18 to d4cc096 Compare December 9, 2024 12:05
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.

@yndajas, I've made the changes that you suggested and left your other comments unresolved. (I've linked to this pull request in the notes for our mobbing session, mentioning the relevance of the discussion here.)

@mike3985 mike3985 merged commit 93735e1 into main Dec 9, 2024
12 checks passed
@mike3985 mike3985 deleted the graphql-news-articles branch December 9, 2024 12:38
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.

3 participants