diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index a7aca354dc..cf1ef6458b 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -339,9 +339,12 @@ const Resolvers = { `unable to get survey list. status(${response.status})` ); } - return { - surveyIdList: response.data, - }; + return response.data.map((survey) => { + return { + surveyId: survey.survey_id, + surveyName: survey.survey_name, + }; + }); } catch (err) { logger.error(err.message); return { diff --git a/eq-author-api/schema/tests/SupplementaryDataSurveyIdList.test.js b/eq-author-api/schema/tests/SupplementaryDataSurveyIdList.test.js index 30a52baa72..e4df53b9e5 100644 --- a/eq-author-api/schema/tests/SupplementaryDataSurveyIdList.test.js +++ b/eq-author-api/schema/tests/SupplementaryDataSurveyIdList.test.js @@ -7,14 +7,19 @@ const fetch = require("node-fetch"); const query = ` query GetSupplementaryDataSurveyIdList { supplementaryDataSurveyIdList { - surveyIdList + surveyId + surveyName } }`; fetch.mockImplementation(() => Promise.resolve({ status: 200, - json: () => ["121", "122", "123"], + json: () => [ + { survey_id: "121", survey_name: "survey1" }, + { survey_id: "122", survey_name: "survey2" }, + { survey_id: "123", survey_name: "survey3" }, + ], }) ); @@ -22,9 +27,11 @@ describe("SupplementaryDataSurveyIdList", () => { it("should query supplementary data survey id list schema", async () => { const expectedResponse = { data: { - supplementaryDataSurveyIdList: { - surveyIdList: ["121", "122", "123"], - }, + supplementaryDataSurveyIdList: [ + { surveyId: "121", surveyName: "survey1" }, + { surveyId: "122", surveyName: "survey2" }, + { surveyId: "123", surveyName: "survey3" }, + ], }, }; diff --git a/eq-author-api/schema/typeDefs.js b/eq-author-api/schema/typeDefs.js index 56508a7c85..eb4ec846dd 100644 --- a/eq-author-api/schema/typeDefs.js +++ b/eq-author-api/schema/typeDefs.js @@ -850,7 +850,8 @@ type SupplementaryDataVersions { } type SupplementaryDataSurveyIdList { - surveyIdList: [String]! + surveyId: String! + surveyName: String } type SupplementaryDataField { @@ -912,7 +913,7 @@ type Query { collectionLists: CollectionLists list(input: QueryInput!): List supplementaryDataVersions(id: ID!): SupplementaryDataVersions - supplementaryDataSurveyIdList: SupplementaryDataSurveyIdList + supplementaryDataSurveyIdList: [SupplementaryDataSurveyIdList] supplementaryData: SupplementaryData publishHistory: [PublishHistoryEvent] listNames: [ListName] diff --git a/eq-author/src/App/dataSettings/SupplementaryDataPage/index.js b/eq-author/src/App/dataSettings/SupplementaryDataPage/index.js index 8638c93d55..4c3f7cdba8 100644 --- a/eq-author/src/App/dataSettings/SupplementaryDataPage/index.js +++ b/eq-author/src/App/dataSettings/SupplementaryDataPage/index.js @@ -169,7 +169,7 @@ const SupplementaryDataPage = () => { const schemaData = tableData?.data; const surveyIdList = - supplementaryDataSurveyIdList?.supplementaryDataSurveyIdList?.surveyIdList; + supplementaryDataSurveyIdList?.supplementaryDataSurveyIdList; const handleUnlinkClick = () => { setShowUnlinkModal(true); @@ -244,9 +244,12 @@ const SupplementaryDataPage = () => { > Survey ID - {surveyIdList?.map((surveyID) => ( - ))} diff --git a/eq-author/src/App/dataSettings/SupplementaryDataPage/index.test.js b/eq-author/src/App/dataSettings/SupplementaryDataPage/index.test.js index 05d83d837e..c3b823eb5f 100644 --- a/eq-author/src/App/dataSettings/SupplementaryDataPage/index.test.js +++ b/eq-author/src/App/dataSettings/SupplementaryDataPage/index.test.js @@ -112,9 +112,10 @@ describe("Supplementary dataset page", () => { } else if (key === GET_SUPPLEMENTARY_DATA_SURVEY_ID_LIST) { return { data: { - supplementaryDataSurveyIdList: { - surveyIdList: ["121", "122"], - }, + supplementaryDataSurveyIdList: [ + { surveyId: "121", surveyName: "survey1" }, + { surveyId: "122", surveyName: "survey2" }, + ], }, }; } else { diff --git a/eq-author/src/graphql/getSupplementaryDataSurveyIdList.graphql b/eq-author/src/graphql/getSupplementaryDataSurveyIdList.graphql index a38f878243..eb95dd5cbf 100644 --- a/eq-author/src/graphql/getSupplementaryDataSurveyIdList.graphql +++ b/eq-author/src/graphql/getSupplementaryDataSurveyIdList.graphql @@ -1,5 +1,6 @@ query GetSupplementaryDataSurveyIdList { supplementaryDataSurveyIdList { - surveyIdList + surveyId + surveyName } }