Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@graphql-codegen/typescript-resolvers": "^5.1.7",
"@graphql-eslint/eslint-plugin": "^4.4.0",
"@graphql-tools/mock": "^9.1.5",
"@ndla/types-backend": "^1.0.106",
"@ndla/types-backend": "^1.0.107",
"@ndla/types-embed": "^5.0.21-alpha.0",
"@ndla/types-taxonomy": "^1.0.50",
"@types/compression": "^1.8.1",
Expand Down
12 changes: 11 additions & 1 deletion src/api/articleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

import { paths, ArticleV2DTO } from "@ndla/types-backend/article-api";
import { paths, ArticleV2DTO, ArticleRevisionHistoryDTO } from "@ndla/types-backend/article-api";
import { ndlaUrl } from "../config";
import {
GQLArticleTransformedContentArgs,
Expand Down Expand Up @@ -212,3 +212,13 @@ export async function fetchRevisions(articleId: number, _: Context): Promise<num
})
.then(resolveJsonOATS);
}

export async function fetchRevisionHistory(articleId: number, _: Context): Promise<ArticleRevisionHistoryDTO> {
return await client
.GET("/article-api/v2/articles/{article_id}/revision-history", {
params: {
path: { article_id: articleId },
},
})
.then(resolveJsonOATS);
}
11 changes: 10 additions & 1 deletion src/resolvers/articleResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

import { ArticleV2DTO } from "@ndla/types-backend/article-api";
import { ArticleV2DTO, ArticleRevisionHistoryDTO } from "@ndla/types-backend/article-api";
import { ConceptSummaryDTO } from "@ndla/types-backend/concept-api";
import { fetchSubjectTopics, searchConcepts } from "../api";
import {
Expand All @@ -16,6 +16,7 @@ import {
fetchVisualElementEmbed,
fetchRevisions,
fetchArticle,
fetchRevisionHistory,
} from "../api/articleApi";
import { coreElements, fetchCrossSubjectTopicsByCode, grepSearch } from "../api/searchApi";
import { ndlaUrl } from "../config";
Expand All @@ -26,6 +27,7 @@ import {
GQLCrossSubjectElement,
GQLImageMetaInformationV3,
GQLQueryArticleArgs,
GQLQueryRevisionHistoryArgs,
GQLQueryRevisionsArgs,
GQLRelatedContent,
GQLResourceEmbed,
Expand All @@ -39,6 +41,13 @@ export const Query = {
async revisions(_: any, { articleId }: GQLQueryRevisionsArgs, context: ContextWithLoaders): Promise<number[]> {
return fetchRevisions(articleId, context);
},
async revisionHistory(
_: any,
{ id }: GQLQueryRevisionHistoryArgs,
context: ContextWithLoaders,
): Promise<ArticleRevisionHistoryDTO> {
return fetchRevisionHistory(id, context);
},
};

export const resolvers = {
Expand Down
5 changes: 5 additions & 0 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,10 @@ export const typeDefs = gql`
url: String!
}

type ArticleRevisionHistory {
revision: [Article!]!
}

type Article {
id: Int!
revision: Int!
Expand Down Expand Up @@ -1549,6 +1553,7 @@ export const typeDefs = gql`
allMyNdlaResources(size: Int): [MyNdlaResource!]!
recentlyFavoritedResources(size: Int): [MyNdlaResource!]!
revisions(articleId: Int!): [Int!]!
revisionHistory(id: Int!): ArticleRevisionHistory
personalData: MyNdlaPersonalData
image(id: String!): ImageMetaInformationV3
examLockStatus: ConfigMetaBoolean!
Expand Down
19 changes: 19 additions & 0 deletions src/types/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export type GQLArticleRequiredLibrary = {
url: Scalars['String']['output'];
};

export type GQLArticleRevisionHistory = {
__typename?: 'ArticleRevisionHistory';
revision: Array<GQLArticle>;
};

export type GQLArticleSearchResult = GQLSearchResult & {
__typename?: 'ArticleSearchResult';
context?: Maybe<GQLSearchContext>;
Expand Down Expand Up @@ -1449,6 +1454,7 @@ export type GQLQuery = {
resourceEmbed: GQLResourceEmbed;
resourceEmbeds: GQLResourceEmbed;
resourceTypes?: Maybe<Array<GQLResourceTypeDefinition>>;
revisionHistory?: Maybe<GQLArticleRevisionHistory>;
revisions: Array<Scalars['Int']['output']>;
search?: Maybe<GQLSearch>;
searchWithoutPagination?: Maybe<GQLSearchWithoutPagination>;
Expand Down Expand Up @@ -1674,6 +1680,11 @@ export type GQLQueryResourceEmbedsArgs = {
};


export type GQLQueryRevisionHistoryArgs = {
id: Scalars['Int']['input'];
};


export type GQLQueryRevisionsArgs = {
articleId: Scalars['Int']['input'];
};
Expand Down Expand Up @@ -2300,6 +2311,7 @@ export type GQLResolversTypes = {
Article: ResolverTypeWrapper<GQLArticle>;
ArticleMetaData: ResolverTypeWrapper<GQLArticleMetaData>;
ArticleRequiredLibrary: ResolverTypeWrapper<GQLArticleRequiredLibrary>;
ArticleRevisionHistory: ResolverTypeWrapper<GQLArticleRevisionHistory>;
ArticleSearchResult: ResolverTypeWrapper<GQLArticleSearchResult>;
Audio: ResolverTypeWrapper<GQLAudio>;
AudioFile: ResolverTypeWrapper<GQLAudioFile>;
Expand Down Expand Up @@ -2467,6 +2479,7 @@ export type GQLResolversParentTypes = {
Article: GQLArticle;
ArticleMetaData: GQLArticleMetaData;
ArticleRequiredLibrary: GQLArticleRequiredLibrary;
ArticleRevisionHistory: GQLArticleRevisionHistory;
ArticleSearchResult: GQLArticleSearchResult;
Audio: GQLAudio;
AudioFile: GQLAudioFile;
Expand Down Expand Up @@ -2691,6 +2704,10 @@ export type GQLArticleRequiredLibraryResolvers<ContextType = any, ParentType ext
url?: Resolver<GQLResolversTypes['String'], ParentType, ContextType>;
};

export type GQLArticleRevisionHistoryResolvers<ContextType = any, ParentType extends GQLResolversParentTypes['ArticleRevisionHistory'] = GQLResolversParentTypes['ArticleRevisionHistory']> = {
revision?: Resolver<Array<GQLResolversTypes['Article']>, ParentType, ContextType>;
};

export type GQLArticleSearchResultResolvers<ContextType = any, ParentType extends GQLResolversParentTypes['ArticleSearchResult'] = GQLResolversParentTypes['ArticleSearchResult']> = {
context?: Resolver<Maybe<GQLResolversTypes['SearchContext']>, ParentType, ContextType>;
contexts?: Resolver<Array<GQLResolversTypes['SearchContext']>, ParentType, ContextType>;
Expand Down Expand Up @@ -3644,6 +3661,7 @@ export type GQLQueryResolvers<ContextType = any, ParentType extends GQLResolvers
resourceEmbed?: Resolver<GQLResolversTypes['ResourceEmbed'], ParentType, ContextType, RequireFields<GQLQueryResourceEmbedArgs, 'id' | 'type'>>;
resourceEmbeds?: Resolver<GQLResolversTypes['ResourceEmbed'], ParentType, ContextType, RequireFields<GQLQueryResourceEmbedsArgs, 'resources'>>;
resourceTypes?: Resolver<Maybe<Array<GQLResolversTypes['ResourceTypeDefinition']>>, ParentType, ContextType>;
revisionHistory?: Resolver<Maybe<GQLResolversTypes['ArticleRevisionHistory']>, ParentType, ContextType, RequireFields<GQLQueryRevisionHistoryArgs, 'id'>>;
revisions?: Resolver<Array<GQLResolversTypes['Int']>, ParentType, ContextType, RequireFields<GQLQueryRevisionsArgs, 'articleId'>>;
search?: Resolver<Maybe<GQLResolversTypes['Search']>, ParentType, ContextType, Partial<GQLQuerySearchArgs>>;
searchWithoutPagination?: Resolver<Maybe<GQLResolversTypes['SearchWithoutPagination']>, ParentType, ContextType, Partial<GQLQuerySearchWithoutPaginationArgs>>;
Expand Down Expand Up @@ -4001,6 +4019,7 @@ export type GQLResolvers<ContextType = any> = {
Article?: GQLArticleResolvers<ContextType>;
ArticleMetaData?: GQLArticleMetaDataResolvers<ContextType>;
ArticleRequiredLibrary?: GQLArticleRequiredLibraryResolvers<ContextType>;
ArticleRevisionHistory?: GQLArticleRevisionHistoryResolvers<ContextType>;
ArticleSearchResult?: GQLArticleSearchResultResolvers<ContextType>;
Audio?: GQLAudioResolvers<ContextType>;
AudioFile?: GQLAudioFileResolvers<ContextType>;
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1781,10 +1781,10 @@ __metadata:
languageName: node
linkType: hard

"@ndla/types-backend@npm:^1.0.106":
version: 1.0.106
resolution: "@ndla/types-backend@npm:1.0.106"
checksum: 10c0/c951aa4743611e148e1a413f475bce1347cdc89585cdb6cc77c2d0fc4bb1f952c96642207039007e8d4d3a9a6c7f7582bddc16670a0ea03dbc4580578cb664f3
"@ndla/types-backend@npm:^1.0.107":
version: 1.0.107
resolution: "@ndla/types-backend@npm:1.0.107"
checksum: 10c0/9c24f97311e319eef76d46d18127734228df7b42bffa531d024f1fe6fec72fa38394e1b9f890bcc82fa709b5d4d0ec12b8008ebb909b274935d991d6cfcbdb98
languageName: node
linkType: hard

Expand Down Expand Up @@ -6472,7 +6472,7 @@ __metadata:
"@graphql-tools/mock": "npm:^9.1.5"
"@graphql-tools/schema": "npm:^10.0.31"
"@ndla/licenses": "npm:^9.0.3"
"@ndla/types-backend": "npm:^1.0.106"
"@ndla/types-backend": "npm:^1.0.107"
"@ndla/types-embed": "npm:^5.0.21-alpha.0"
"@ndla/types-taxonomy": "npm:^1.0.50"
"@types/compression": "npm:^1.8.1"
Expand Down
Loading