Skip to content

Commit abc9295

Browse files
Merge pull request #57 from code-kern-ai/graphql-data-removal
Removal of GraphQL Data Return Schema
2 parents 809f5ac + ad2e54f commit abc9295

File tree

49 files changed

+169
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+169
-280
lines changed

src/components/models-download/ModelsDownload.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function ModelsDownload() {
2929

3030
function refetchModels() {
3131
getModelProviderInfo((res) => {
32-
dispatch(setModelsDownloaded(res.data['modelProviderInfo']));
32+
dispatch(setModelsDownloaded(res));
3333
});
3434
}
3535

src/components/projects/ProjectsList.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,15 @@ export default function ProjectsList() {
4949

5050
function refetchProjectsAndPostProcess() {
5151
getAllProjects((res) => {
52-
const projects = res.data["allProjects"].edges.map((edge: any) => edge.node);
53-
dispatch(setAllProjects(projects));
52+
dispatch(setAllProjects(res));
5453
setDataLoaded(true);
5554
});
5655
}
5756

5857
function refetchStatsAndPostProcess() {
5958
getOverviewStats((res) => {
60-
const stats = res.data["overviewStats"];
61-
const statsDict = {};
62-
if (stats == null) return;
63-
stats.forEach((stat: ProjectStatistics) => {
64-
const statCopy = { ...stat };
65-
stat.manuallyLabeled = percentRoundString(statCopy.numDataScaleManual / statCopy.numDataScaleUploaded, 2);
66-
stat.weaklySupervised = percentRoundString(statCopy.numDataScaleProgrammatical / statCopy.numDataScaleUploaded, 2);
67-
statsDict[stat.projectId] = stat;
68-
});
69-
setProjectStatisticsById(statsDict);
59+
if (res == null) return;
60+
setProjectStatisticsById(res);
7061
});
7162
}
7263

src/components/projects/SampleProjectsDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function SampleProjectsDropdown() {
4040
dispatch(setSearchGroupsStore({}));
4141
createSampleProject({ name: projectNameFinal, projectType: projectTypeFinal }, (res) => {
4242
dispatch(closeModal(ModalEnum.SAMPLE_PROJECT_TITLE));
43-
const projectId = res['data']['createSampleProject']['project'].id;
43+
const projectId = res?.id;
4444
dispatch(setProjectIdSampleProject(projectId));
4545
});
4646
}, [projects, projectNameInput, projectTypeInput, router]);

src/components/projects/new/NewProject.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export default function NewProject() {
1919
useEffect(() => {
2020
dispatch(setUploadFileType(COMPONENT_FILE_TYPE));
2121
getAllProjects((res) => {
22-
const projects = res.data["allProjects"].edges.map((edge: any) => edge.node);
23-
dispatch(setAllProjects(projects));
22+
dispatch(setAllProjects(res));
2423
});
2524
}, []);
2625

src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { CommentType } from "@/src/types/shared/comments";
2727
import { AttributeCodeLookup } from "@/src/util/classes/attribute-calculation";
2828
import KernDropdown from "@/submodules/react-components/components/KernDropdown";
2929
import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/useWebsocket";
30-
import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper";
30+
import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper";
3131
import { getAllComments } from "@/src/services/base/comment";
3232
import { getAttributes } from "@/src/services/base/attribute";
3333
import { getLookupListsByProjectId } from "@/src/services/base/lookup-lists";
@@ -65,15 +65,15 @@ export default function AttributeCalculation() {
6565
if (!projectId) return;
6666
if (!currentAttribute || attributes.length == 0) {
6767
getAttributes(projectId, ['ALL'], (res) => {
68-
dispatch(setAllAttributes(res.data['attributesByProjectId']));
68+
dispatch(setAllAttributes(res));
6969
const currentAttribute = postProcessCurrentAttribute(attributes.find((attribute) => attribute.id === router.query.attributeId));
7070
setCurrentAttribute(currentAttribute);
7171
setEditorValue(currentAttribute?.sourceCodeToDisplay);
7272
});
7373
}
7474
if (lookupLists.length == 0) {
7575
getLookupListsByProjectId(projectId, (res) => {
76-
dispatch(setAllLookupLists(res.data['knowledgeBasesByProjectId']));
76+
dispatch(setAllLookupLists(res));
7777
});
7878
}
7979
refetchLabelingTasksAndProcess();
@@ -136,7 +136,7 @@ export default function AttributeCalculation() {
136136
CommentDataManager.registerCommentRequests(CurrentPage.ATTRIBUTE_CALCULATION, requests);
137137
const requestJsonString = CommentDataManager.buildRequestJSON();
138138
getAllComments(requestJsonString, (res) => {
139-
CommentDataManager.parseCommentData(res.data['getAllComments']);
139+
CommentDataManager.parseCommentData(res);
140140
CommentDataManager.parseToCurrentData(allUsers);
141141
dispatch(setComments(CommentDataManager.currentDataOrder));
142142
});
@@ -221,14 +221,13 @@ export default function AttributeCalculation() {
221221

222222
function checkProjectTokenization() {
223223
getProjectTokenization(projectId, (res) => {
224-
setTokenizationProgress(res.data['projectTokenization']?.progress);
224+
setTokenizationProgress(res?.progress);
225225
});
226226
}
227227

228228
function refetchLabelingTasksAndProcess() {
229229
getLabelingTasksByProjectId(projectId, (res) => {
230-
const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']);
231-
dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks)));
230+
dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res)));
232231
});
233232
}
234233

@@ -243,11 +242,11 @@ export default function AttributeCalculation() {
243242
setCurrentAttribute(currentAttributeCopy);
244243
} else {
245244
getAttributes(projectId, ['ALL'], (res) => {
246-
dispatch(setAllAttributes(res.data['attributesByProjectId']));
245+
dispatch(setAllAttributes(res));
247246
});
248-
getAttributeByAttributeId(projectId, currentAttribute?.id, (res) => {
249-
const attribute = res.data['attributeByAttributeId'];
250-
if (attribute == null) setCurrentAttribute(null);
247+
if (msgParts[2] == 'deleted') return
248+
getAttributeByAttributeId(projectId, currentAttribute?.id, (attribute) => {
249+
if (!attribute) setCurrentAttribute(null);
251250
else setCurrentAttribute(postProcessCurrentAttribute(attribute));
252251
});
253252
if (msgParts[2] == "finished") {
@@ -256,7 +255,7 @@ export default function AttributeCalculation() {
256255
}
257256
} else if (['knowledge_base_updated', 'knowledge_base_deleted', 'knowledge_base_created'].includes(msgParts[1])) {
258257
getLookupListsByProjectId(projectId, (res) => {
259-
dispatch(setAllLookupLists(res.data['knowledgeBasesByProjectId']));
258+
dispatch(setAllLookupLists(res));
260259
});
261260
} else if (msgParts[1] == 'tokenization' && msgParts[2] == 'docbin') {
262261
if (msgParts[3] == 'progress') {
@@ -388,8 +387,7 @@ export default function AttributeCalculation() {
388387
<ExecutionContainer currentAttribute={currentAttribute} tokenizationProgress={tokenizationProgress} enableRunButton={enableRunButton} checkUnsavedChanges={checkUnsavedChanges}
389388
setEnabledButton={(value: boolean) => setEnableButton(value)}
390389
refetchCurrentAttribute={() => {
391-
getAttributeByAttributeId(projectId, currentAttribute?.id, (res) => {
392-
const attribute = res.data['attributeByAttributeId'];
390+
getAttributeByAttributeId(projectId, currentAttribute?.id, (attribute) => {
393391
if (attribute == null) setCurrentAttribute(null);
394392
else setCurrentAttribute(postProcessCurrentAttribute(attribute));
395393
});

src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
3737
if (requestedSomething) return;
3838
setRequestedSomething(true);
3939
getSampleRecords(projectId, props.currentAttribute.id, (res) => {
40-
const sampleRecordsFinal = { ...res.data['calculateUserAttributeSampleRecords'] };
40+
const sampleRecordsFinal = { ...res };
4141
setRequestedSomething(false);
4242
props.setEnabledButton(false);
4343
setRunOn10HasError(sampleRecordsFinal.calculatedAttributes.length > 0 ? false : true);
@@ -53,7 +53,7 @@ export default function ExecutionContainer(props: ExecutionContainerProps) {
5353

5454
function recordByRecordId(recordId: string) {
5555
getRecordByRecordId(projectId, recordId, (res) => {
56-
dispatch(setModalStates(ModalEnum.VIEW_RECORD_DETAILS, { record: postProcessRecordByRecordId(res.data['recordByRecordId']) }));
56+
dispatch(setModalStates(ModalEnum.VIEW_RECORD_DETAILS, { record: postProcessRecordByRecordId(res) }));
5757
});
5858
}
5959

src/components/projects/projectId/data-browser/DataBrowser.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react";
55
import { expandRecordList, selectActiveSearchParams, selectActiveSlice, selectConfiguration, selectFullSearchStore, selectRecords, setActiveDataSlice, setDataSlices, setRecordComments, setUniqueValuesDict, updateAdditionalDataState } from "@/src/reduxStore/states/pages/data-browser";
66
import { postProcessRecordsExtended, postProcessUniqueValues } from "@/src/util/components/projects/projectId/data-browser/data-browser-helper";
77
import { selectAttributes, selectLabelingTasksAll, setAllAttributes, setAllEmbeddings, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings";
8-
import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper";
8+
import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper";
99
import { selectAllUsers, selectOrganizationId, selectUser, setComments } from "@/src/reduxStore/states/general";
1010
import DataBrowserRecords from "./DataBrowserRecords";
1111
import { postProcessingEmbeddings } from "@/src/util/components/projects/projectId/settings/embeddings-helper";
@@ -64,12 +64,12 @@ export default function DataBrowser() {
6464
getRecordsByStaticSlice(projectId, activeSlice.id, {
6565
offset: searchRequest.offset, limit: searchRequest.limit
6666
}, (res) => {
67-
dispatch(expandRecordList(postProcessRecordsExtended(res.data['recordsByStaticSlice'], labelingTasks)));
67+
dispatch(expandRecordList(postProcessRecordsExtended(res, labelingTasks)));
6868
});
6969
} else {
7070
const filterData = parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, fullSearchStore[SearchGroup.DRILL_DOWN])
7171
searchRecordsExtended(projectId, filterData, searchRequest.offset, searchRequest.limit, (res) => {
72-
const parsedRecordData = postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks);
72+
const parsedRecordData = postProcessRecordsExtended(res, labelingTasks);
7373
dispatch(expandRecordList(parsedRecordData));
7474
refetchRecordCommentsAndProcess(parsedRecordData.recordList);
7575
});
@@ -93,38 +93,37 @@ export default function DataBrowser() {
9393
CommentDataManager.registerCommentRequests(CurrentPage.DATA_BROWSER, requests);
9494
const requestJsonString = CommentDataManager.buildRequestJSON();
9595
getAllComments(requestJsonString, (res) => {
96-
CommentDataManager.parseCommentData(res.data['getAllComments']);
96+
CommentDataManager.parseCommentData(res);
9797
CommentDataManager.parseToCurrentData(users);
9898
dispatch(setComments(CommentDataManager.currentDataOrder));
9999
});
100100
}
101101

102102
function refetchDataSlicesAndProcess(dataSliceId?: string) {
103103
getDataSlices(projectId, null, (res) => {
104-
dispatch(setDataSlices(res.data.dataSlices));
104+
dispatch(setDataSlices(res));
105105
if (dataSliceId) {
106-
const findSlice = res.data.dataSlices.find((slice) => slice.id == dataSliceId);
106+
const findSlice = res.find((slice) => slice.id == dataSliceId);
107107
if (findSlice) dispatch(setActiveDataSlice(findSlice));
108108
}
109109
});
110110
}
111111

112112
function refetchAttributesAndProcess() {
113113
getAttributes(projectId, ['ALL'], (res) => {
114-
dispatch(setAllAttributes(res.data['attributesByProjectId']));
114+
dispatch(setAllAttributes(res));
115115
});
116116
}
117117

118118
function refetchLabelingTasksAndProcess() {
119119
getLabelingTasksByProjectId(projectId, (res) => {
120-
const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']);
121-
dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks)));
120+
dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(res)));
122121
});
123122
}
124123

125124
function refetchEmbeddingsAndPostProcess() {
126125
getEmbeddings(projectId, (res) => {
127-
const embeddings = postProcessingEmbeddings(res.data['projectByProjectId']['embeddings']['edges'].map((e) => e['node']), []);
126+
const embeddings = postProcessingEmbeddings(res, []);
128127
dispatch(setAllEmbeddings(embeddings));
129128
});
130129
}
@@ -133,7 +132,7 @@ export default function DataBrowser() {
133132
const currentRecordIds = parsedRecordData?.map((record) => record.id);
134133
if (!currentRecordIds || currentRecordIds.length == 0) return;
135134
getRecordComments(projectId, currentRecordIds, (res) => {
136-
dispatch(setRecordComments(res.data['getRecordComments']));
135+
dispatch(setRecordComments(res));
137136
});
138137
}
139138

@@ -143,7 +142,7 @@ export default function DataBrowser() {
143142

144143
function refetchUniqueValuesAndProcess() {
145144
getUniqueValuesByAttributes(projectId, (res) => {
146-
dispatch(setUniqueValuesDict(postProcessUniqueValues(res.data['uniqueValuesByAttributes'], attributes)));
145+
dispatch(setUniqueValuesDict(postProcessUniqueValues(res, attributes)));
147146
});
148147
}
149148

src/components/projects/projectId/data-browser/SearchGroups.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default function SearchGroups() {
112112
dispatch(updateAdditionalDataState('loading', true));
113113
const refetchTimer = setTimeout(() => {
114114
searchRecordsExtended(projectId, parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, fullSearchStore[SearchGroup.DRILL_DOWN]), 0, 20, (res) => {
115-
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['searchRecordsExtended'], labelingTasks)));
115+
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res, labelingTasks)));
116116
dispatch(updateAdditionalDataState('loading', false));
117117
});
118118
}, 500);
@@ -133,14 +133,14 @@ export default function SearchGroups() {
133133
options.limit = 20;
134134
}
135135
getRecordsByStaticSlice(projectId, activeSlice.id, options, (res) => {
136-
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['recordsByStaticSlice'], labelingTasks)));
136+
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res, labelingTasks)));
137137
staticDataSlicesCurrentCount(projectId, activeSlice.id, (res) => {
138-
if (!res.data) {
138+
if (!res) {
139139
dispatch(updateAdditionalDataState('staticDataSliceCurrentCount', null));
140140
return;
141141

142142
}
143-
dispatch(updateAdditionalDataState('staticDataSliceCurrentCount', res['data']['staticDataSlicesCurrentCount']));
143+
dispatch(updateAdditionalDataState('staticDataSliceCurrentCount', res));
144144
});
145145
});
146146
}
@@ -569,7 +569,7 @@ export default function SearchGroups() {
569569
if (res == null) {
570570
setCurrentWeakSupervisionRun({ state: Status.NOT_YET_RUN });
571571
} else {
572-
setCurrentWeakSupervisionRun(postProcessCurrentWeakSupervisionRun(res['data']['currentWeakSupervisionRun']));
572+
setCurrentWeakSupervisionRun(postProcessCurrentWeakSupervisionRun(res));
573573
}
574574
});
575575
}

src/components/projects/projectId/data-browser/modals/SaveDataSliceModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function SaveDataSliceModal(props: { fullSearch: {} }) {
3737
filterRaw: getRawFilterForSave(props.fullSearch),
3838
filterData: parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, props.fullSearch[SearchGroup.DRILL_DOWN].value)
3939
}, (res) => {
40-
const id = res["data"]["createDataSlice"]["id"];
40+
const id = res?.id;
4141
const slice = {
4242
id: id, name: modalSaveDataSlice.sliceName, static: isStatic, filterRaw: getRawFilterForSave(props.fullSearch),
4343
filterData: parseFilterToExtended(activeSearchParams, attributes, configuration, labelingTasks, user, props.fullSearch[SearchGroup.DRILL_DOWN].value), color: getColorStruct(isStatic),

src/components/projects/projectId/data-browser/modals/SimilaritySeachModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function SimilaritySearchModal() {
4545
function getSimilarRecords(hasFilter: boolean = false) {
4646
const attFilter = hasFilter ? prepareAttFilter(filterAttributesForm, attributes) : null;
4747
getRecordsBySimilarity(projectId, selectedEmbedding.id, modalSS.recordId, attFilter, null, (res) => {
48-
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res.data['searchRecordsBySimilarity'], labelingTasks)));
48+
dispatch(setSearchRecordsExtended(postProcessRecordsExtended(res, labelingTasks)));
4949
dispatch(setRecordsInDisplay(true));
5050
});
5151
}

0 commit comments

Comments
 (0)