From 053640ed2cd0c05d4a5f6c0cea34d7b5d1cf214a Mon Sep 17 00:00:00 2001 From: Katrine Wist Date: Tue, 5 Sep 2023 15:56:44 +0200 Subject: [PATCH] Add language to content and title in Article --- src/api/articleApi.ts | 16 +++++++++------- src/schema.ts | 9 +++++++-- src/types/schema.d.ts | 23 +++++++++++++++++++---- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/api/articleApi.ts b/src/api/articleApi.ts index 69559d7e..e6f53ff0 100644 --- a/src/api/articleApi.ts +++ b/src/api/articleApi.ts @@ -86,16 +86,18 @@ const _fetchTransformedArticle = async ( ...article, introduction: article.introduction?.introduction ?? '', metaDescription: article.metaDescription.metaDescription, - title: article.title.title, metaData, tags: article.tags.tags, visualElementEmbed, - content: - article.articleType === 'standard' - ? content - : content === '
' - ? '' - : content, + content: { + ...article.content, + content: + article.articleType === 'standard' + ? content + : content === '
' + ? '' + : content, + }, visualElement, }; } diff --git a/src/schema.ts b/src/schema.ts index 03a31d56..eae5b94f 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -486,13 +486,18 @@ export const typeDefs = gql` url: String! } + type Content { + content: String! + language: String! + } + type Article { id: Int! revision: Int! - title: String! + title: Title! slug: String introduction: String - content: String! + content: Content! created: String! updated: String! published: String! diff --git a/src/types/schema.d.ts b/src/types/schema.d.ts index 3a561728..6fb366ee 100644 --- a/src/types/schema.d.ts +++ b/src/types/schema.d.ts @@ -30,7 +30,7 @@ export type GQLArticle = { competenceGoals?: Maybe>; conceptIds?: Maybe>; concepts?: Maybe>; - content: Scalars['String']; + content: GQLContent; copyright: GQLCopyright; coreElements?: Maybe>; created: Scalars['String']; @@ -51,7 +51,7 @@ export type GQLArticle = { slug?: Maybe; supportedLanguages?: Maybe>; tags?: Maybe>; - title: Scalars['String']; + title: GQLTitle; updated: Scalars['String']; visualElement?: Maybe; visualElementEmbed?: Maybe; @@ -319,6 +319,12 @@ export type GQLConfigMetaRestricted = { value: Scalars['String']; }; +export type GQLContent = { + __typename?: 'Content'; + content: Scalars['String']; + language: Scalars['String']; +}; + export type GQLContributor = { __typename?: 'Contributor'; name: Scalars['String']; @@ -1745,6 +1751,7 @@ export type GQLResolversTypes = { ConceptLicense: ResolverTypeWrapper; ConceptResult: ResolverTypeWrapper; ConfigMetaRestricted: ResolverTypeWrapper; + Content: ResolverTypeWrapper; Contributor: ResolverTypeWrapper; Copyright: ResolverTypeWrapper; CoreElement: ResolverTypeWrapper; @@ -1883,6 +1890,7 @@ export type GQLResolversParentTypes = { ConceptLicense: GQLConceptLicense; ConceptResult: GQLConceptResult; ConfigMetaRestricted: GQLConfigMetaRestricted; + Content: GQLContent; Contributor: GQLContributor; Copyright: GQLCopyright; CoreElement: GQLCoreElement; @@ -2005,7 +2013,7 @@ export type GQLArticleResolvers>, ParentType, ContextType>; conceptIds?: Resolver>, ParentType, ContextType>; concepts?: Resolver>, ParentType, ContextType>; - content?: Resolver; + content?: Resolver; copyright?: Resolver; coreElements?: Resolver>, ParentType, ContextType>; created?: Resolver; @@ -2026,7 +2034,7 @@ export type GQLArticleResolvers, ParentType, ContextType>; supportedLanguages?: Resolver>, ParentType, ContextType>; tags?: Resolver>, ParentType, ContextType>; - title?: Resolver; + title?: Resolver; updated?: Resolver; visualElement?: Resolver, ParentType, ContextType>; visualElementEmbed?: Resolver, ParentType, ContextType>; @@ -2290,6 +2298,12 @@ export type GQLConfigMetaRestrictedResolvers; }; +export type GQLContentResolvers = { + content?: Resolver; + language?: Resolver; + __isTypeOf?: IsTypeOfResolverFn; +}; + export type GQLContributorResolvers = { name?: Resolver; type?: Resolver; @@ -3288,6 +3302,7 @@ export type GQLResolvers = { ConceptLicense?: GQLConceptLicenseResolvers; ConceptResult?: GQLConceptResultResolvers; ConfigMetaRestricted?: GQLConfigMetaRestrictedResolvers; + Content?: GQLContentResolvers; Contributor?: GQLContributorResolvers; Copyright?: GQLCopyrightResolvers; CoreElement?: GQLCoreElementResolvers;