move apiRequest to reduce circular dependencies

Change-Id: I60446bd1e2141160b8fcbc0e13973b89bfe31d07
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/335751
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Michael Hulse <michael.hulse@instructure.com>
QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
This commit is contained in:
Aaron Shafovaloff 2023-12-20 14:46:38 -05:00
parent f56735663d
commit dc4f0a11c9
13 changed files with 16 additions and 15 deletions

View File

@ -18,7 +18,7 @@
import React from 'react'
import {useScope as useI18nScope} from '@canvas/i18n'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
import type {HandleCheckboxChange} from '../../../types'
import CheckboxTemplate from './CheckboxTemplate'

View File

@ -19,7 +19,7 @@
import React from 'react'
import {useScope as useI18nScope} from '@canvas/i18n'
import type {CustomColumn, HandleCheckboxChange, TeacherNotes} from '../../../types'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
import CheckboxTemplate from './CheckboxTemplate'
const I18n = useI18nScope('enhanced_individual_gradebook')

View File

@ -30,13 +30,13 @@ import {
} from './fixtures'
import {GRADEBOOK_SUBMISSION_COMMENTS} from '../../../../queries/Queries'
import {MockedProvider} from '@apollo/react-testing'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
import type {
AssignmentConnection,
GradebookUserSubmissionDetails,
} from 'features/enhanced_individual_gradebook/types'
jest.mock('@canvas/util/apiRequest', () => ({
jest.mock('@canvas/do-fetch-api-effect/apiRequest', () => ({
executeApiRequest: jest.fn(),
}))

View File

@ -28,11 +28,11 @@ import userSettings from '@canvas/user-settings'
import {GradebookSortOrder} from '../../../types/gradebook.d'
import * as ReactRouterDom from 'react-router-dom'
import doFetchApi from '@canvas/do-fetch-api-effect'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
jest.mock('axios') // mock axios for final grade override helper API call
jest.mock('@canvas/do-fetch-api-effect', () => jest.fn()) // mock doFetchApi for final grade override helper API call
jest.mock('@canvas/util/apiRequest', () => ({
jest.mock('@canvas/do-fetch-api-effect/apiRequest', () => ({
executeApiRequest: jest.fn(),
}))
const mockedAxios = axios as jest.Mocked<typeof axios>

View File

@ -19,7 +19,7 @@
import {useCallback, useEffect, useState} from 'react'
import {useQuery} from 'react-apollo'
import {useScope as useI18nScope} from '@canvas/i18n'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
import {GRADEBOOK_SUBMISSION_COMMENTS} from '../../queries/Queries'
import {

View File

@ -18,7 +18,7 @@
import {useEffect, useState} from 'react'
import type {CustomColumn} from '../../types'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
export const useCustomColumns = (getCustomColumnsUrl?: string | null) => {
const [customColumns, setCustomColumns] = useState<CustomColumn[] | null>(null)

View File

@ -17,7 +17,7 @@
*/
import {useCallback, useState} from 'react'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
import {ApiCallStatus, type SubmissionGradeChange} from '../../types'
import {mapToSubmissionGradeChange} from '../../utils/gradebookUtils'

View File

@ -19,7 +19,7 @@
import {useScope as useI18nScope} from '@canvas/i18n'
import {useEffect, useState} from 'react'
import {ApiCallStatus, type CustomColumnDatum} from '../../types'
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
const I18n = useI18nScope('enhanced_individual_gradebook_submit_score')

View File

@ -16,7 +16,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {executeApiRequest} from '@canvas/util/apiRequest'
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
import GradeFormatHelper from '@canvas/grading/GradeFormatHelper'
import {useScope as useI18nScope} from '@canvas/i18n'
import numberHelper from '@canvas/i18n/numberHelper'

View File

@ -37,7 +37,7 @@ import useStore from '../stores'
import {gradeOverrideCustomStatus} from '../FinalGradeOverrides/FinalGradeOverride.utils'
import {useFinalGradeOverrideCustomStatus} from '../hooks/useFinalGradeOverrideCustomStatus'
import {showFlashError} from '@canvas/alerts/react/FlashAlert'
import {ApiCallStatus} from '@canvas/util/apiRequest'
import {ApiCallStatus} from '@canvas/do-fetch-api-effect/apiRequest'
const I18n = useI18nScope('gradebook')

View File

@ -20,7 +20,7 @@ import React from 'react'
import {render, fireEvent} from '@testing-library/react'
import GradeOverrideEntry from '@canvas/grading/GradeEntry/GradeOverrideEntry'
import {ApiCallStatus} from '@canvas/util/apiRequest'
import {ApiCallStatus} from '@canvas/do-fetch-api-effect/apiRequest'
import {TotalGradeOverrideTray, type TotalGradeOverrideTrayProps} from '../TotalGradeOverrideTray'
import useStore from '../../stores'
import * as FinalGradeOverrideHooks from '../../hooks/useFinalGradeOverrideCustomStatus'

View File

@ -19,7 +19,7 @@
import {useState} from 'react'
import {useMutation} from 'react-apollo'
import gql from 'graphql-tag'
import {ApiCallStatus} from '@canvas/util/apiRequest'
import {ApiCallStatus} from '@canvas/do-fetch-api-effect/apiRequest'
const SET_OVERRIDE_STATUS_MUTATION = gql`
mutation SetOverrideStatusMutation(

View File

@ -16,7 +16,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import doFetchApi from '@canvas/do-fetch-api-effect'
import doFetchApi from './index'
export type ApiResponse<T> = {
data: T
@ -36,6 +36,7 @@ export type ApiRequest = {
}
export async function executeApiRequest<T>(request: ApiRequest): Promise<ApiResponse<T>> {
// @ts-expect-error
const {json, response, link} = await doFetchApi(request)
return {