Skip to content

Commit

Permalink
EVG-19815: Remove GET_ prefix from GraphQL queries (evergreen-ci#2046)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored Sep 19, 2023
1 parent c80310a commit f10d2b9
Show file tree
Hide file tree
Showing 169 changed files with 1,059 additions and 1,090 deletions.
13 changes: 5 additions & 8 deletions src/analytics/patch/usePatchAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
PatchQueryVariables,
TaskSortCategory,
} from "gql/generated/types";
import { GET_PATCH } from "gql/queries";
import { PATCH } from "gql/queries";

type Action =
| { name: "Filter Tasks"; filterBy: string }
Expand Down Expand Up @@ -49,13 +49,10 @@ type Action =
| { name: "Open Schedule Tasks Modal" };

export const usePatchAnalytics = (id: string) => {
const { data: eventData } = useQuery<PatchQuery, PatchQueryVariables>(
GET_PATCH,
{
variables: { id },
fetchPolicy: "cache-first",
}
);
const { data: eventData } = useQuery<PatchQuery, PatchQueryVariables>(PATCH, {
variables: { id },
fetchPolicy: "cache-first",
});
const { status } = eventData?.patch || {};

return useAnalyticsRoot<Action>("Patch", {
Expand Down
6 changes: 3 additions & 3 deletions src/analytics/task/useAnnotationAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
AnnotationEventDataQuery,
AnnotationEventDataQueryVariables,
} from "gql/generated/types";
import { GET_ANNOTATION_EVENT_DATA, GET_BUILD_BARON } from "gql/queries";
import { ANNOTATION_EVENT_DATA, BUILD_BARON } from "gql/queries";
import { RequiredQueryParams } from "types/task";
import { queryString } from "utils";

Expand Down Expand Up @@ -36,13 +36,13 @@ export const useAnnotationAnalytics = () => {
const { data: eventData } = useQuery<
AnnotationEventDataQuery,
AnnotationEventDataQueryVariables
>(GET_ANNOTATION_EVENT_DATA, {
>(ANNOTATION_EVENT_DATA, {
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
});

const { data: bbData } = useQuery<BuildBaronQuery, BuildBaronQueryVariables>(
GET_BUILD_BARON,
BUILD_BARON,
{
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
Expand Down
13 changes: 5 additions & 8 deletions src/analytics/task/useTaskAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TaskSortCategory,
TestSortCategory,
} from "gql/generated/types";
import { GET_TASK } from "gql/queries";
import { TASK } from "gql/queries";
import { CommitType } from "pages/task/actionButtons/previousCommits/types";
import { RequiredQueryParams, LogTypes } from "types/task";
import { queryString } from "utils";
Expand Down Expand Up @@ -71,13 +71,10 @@ export const useTaskAnalytics = () => {

const parsed = parseQueryString(location.search);
const execution = Number(parsed[RequiredQueryParams.Execution]);
const { data: eventData } = useQuery<TaskQuery, TaskQueryVariables>(
GET_TASK,
{
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
}
);
const { data: eventData } = useQuery<TaskQuery, TaskQueryVariables>(TASK, {
variables: { taskId: id, execution },
fetchPolicy: "cache-first",
});

const {
failedTestCount,
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/version/useVersionAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
VersionQueryVariables,
TaskSortCategory,
} from "gql/generated/types";
import { GET_VERSION } from "gql/queries";
import { VERSION } from "gql/queries";

type Action =
| { name: "Filter Tasks"; filterBy: string }
Expand Down Expand Up @@ -52,7 +52,7 @@ type Action =

export const useVersionAnalytics = (id: string) => {
const { data: eventData } = useQuery<VersionQuery, VersionQueryVariables>(
GET_VERSION,
VERSION,
{
variables: { id },
fetchPolicy: "cache-first",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Banners/GithubUsernameBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
routes,
} from "constants/routes";
import { UserSettingsQuery } from "gql/generated/types";
import { GET_USER_SETTINGS } from "gql/queries";
import { USER_SETTINGS } from "gql/queries";

export const GithubUsernameBanner = () => {
const { pathname } = useLocation();
Expand All @@ -17,7 +17,7 @@ export const GithubUsernameBanner = () => {

// USER SETTINGS QUERY
const { data: userSettingsData } = useQuery<UserSettingsQuery>(
GET_USER_SETTINGS,
USER_SETTINGS,
{ skip: !isPatchesPage }
);
const { userSettings } = userSettingsData || {};
Expand Down
4 changes: 2 additions & 2 deletions src/components/Banners/ProjectBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ProjectBannerQuery,
ProjectBannerQueryVariables,
} from "gql/generated/types";
import { GET_PROJECT_BANNER } from "gql/queries";
import { PROJECT_BANNER } from "gql/queries";
import { PortalBanner } from "./PortalBanner";

interface ProjectBannerProps {
Expand All @@ -15,7 +15,7 @@ export const ProjectBanner: React.FC<ProjectBannerProps> = ({
const { data: projectBannerData } = useQuery<
ProjectBannerQuery,
ProjectBannerQueryVariables
>(GET_PROJECT_BANNER, {
>(PROJECT_BANNER, {
variables: { identifier: projectIdentifier },
skip: !projectIdentifier,
});
Expand Down
5 changes: 2 additions & 3 deletions src/components/Banners/SlackNotificationBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
UserSettingsQuery,
} from "gql/generated/types";
import { UPDATE_USER_SETTINGS } from "gql/mutations";
import { GET_USER_SETTINGS } from "gql/queries";
import { USER_SETTINGS } from "gql/queries";

const { blue } = palette;

Expand All @@ -41,8 +41,7 @@ export const SlackNotificationBanner = () => {
});

// USER SETTINGS QUERY
const { data: userSettingsData } =
useQuery<UserSettingsQuery>(GET_USER_SETTINGS);
const { data: userSettingsData } = useQuery<UserSettingsQuery>(USER_SETTINGS);
const { userSettings } = userSettingsData || {};
const { notifications, slackUsername: defaultSlackUsername } =
userSettings || {};
Expand Down
4 changes: 2 additions & 2 deletions src/components/CodeChanges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
CodeChangesQueryVariables,
FileDiffsFragment,
} from "gql/generated/types";
import { GET_CODE_CHANGES } from "gql/queries";
import { CODE_CHANGES } from "gql/queries";
import { commits } from "utils";
import { formatZeroIndexForDisplay } from "utils/numbers";

Expand All @@ -30,7 +30,7 @@ export const CodeChanges: React.FC<CodeChangesProps> = ({ patchId }) => {
const { data, error, loading } = useQuery<
CodeChangesQuery,
CodeChangesQueryVariables
>(GET_CODE_CHANGES, {
>(CODE_CHANGES, {
variables: { id: patchId },
});
const { moduleCodeChanges } = data?.patch ?? {};
Expand Down
4 changes: 2 additions & 2 deletions src/components/Content/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { size } from "constants/tokens";
import { newSpruceUser } from "constants/welcomeModalProps";
import { useAuthStateContext } from "context/auth";
import { UserQuery, UserQueryVariables } from "gql/generated/types";
import { GET_USER } from "gql/queries";
import { USER } from "gql/queries";
import { useUserSettings } from "hooks";
import { useAnnouncementToast } from "hooks/useAnnouncementToast";
import { isProduction } from "utils/environmentVariables";
Expand All @@ -33,7 +33,7 @@ export const Layout: React.FC = () => {
// this top-level query is required for authentication to work
// afterware is used at apollo link level to authenticate or deauthenticate user based on response to query
// therefore this could be any query as long as it is top-level
const { data } = useQuery<UserQuery, UserQueryVariables>(GET_USER);
const { data } = useQuery<UserQuery, UserQueryVariables>(USER);
localStorage.setItem("userId", data?.user?.userId ?? "");
const { userSettings } = useUserSettings();
const { useSpruceOptions } = userSettings ?? {};
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getCommitsRoute, getUserPatchesRoute, routes } from "constants/routes";
import { size } from "constants/tokens";
import { useAuthStateContext } from "context/auth";
import { UserQuery, SpruceConfigQuery } from "gql/generated/types";
import { GET_USER, SPRUCE_CONFIG } from "gql/queries";
import { USER, SPRUCE_CONFIG } from "gql/queries";
import { useLegacyUIURL } from "hooks";
import { AuxiliaryDropdown } from "./AuxiliaryDropdown";
import { UserDropdown } from "./UserDropdown";
Expand All @@ -25,7 +25,7 @@ export const Navbar: React.FC = () => {
const legacyURL = useLegacyUIURL();
const { sendEvent } = useNavbarAnalytics();

const { data: userData } = useQuery<UserQuery>(GET_USER);
const { data: userData } = useQuery<UserQuery>(USER);
const { user } = userData || {};
const { userId } = user || {};

Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/UserDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { adminSettingsURL } from "constants/externalResources";
import { PreferencesTabRoutes, getPreferencesRoute } from "constants/routes";
import { useAuthDispatchContext } from "context/auth";
import { UserQuery } from "gql/generated/types";
import { GET_USER } from "gql/queries";
import { USER } from "gql/queries";
import { MenuItemType, NavDropdown } from "./NavDropdown";

export const UserDropdown = () => {
const { data } = useQuery<UserQuery>(GET_USER);
const { data } = useQuery<UserQuery>(USER);
const { user } = data || {};
const { displayName, permissions } = user || {};

Expand Down
8 changes: 4 additions & 4 deletions src/components/HistoryTable/hooks/useTestResults.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
TaskTestSampleQuery,
TaskTestSampleQueryVariables,
} from "gql/generated/types";
import { GET_TASK_TEST_SAMPLE } from "gql/queries";
import { TASK_TEST_SAMPLE } from "gql/queries";
import { act, renderHook, waitFor } from "test_utils";
import { ApolloMock } from "types/gql";
import { TestStatus } from "types/history";
Expand Down Expand Up @@ -241,7 +241,7 @@ const noFilterData: ApolloMock<
TaskTestSampleQueryVariables
> = {
request: {
query: GET_TASK_TEST_SAMPLE,
query: TASK_TEST_SAMPLE,
variables: {
tasks: [
"evergreen_lint_lint_model_distro_d4cf298cf0b2536fb3bff875775b93a9ceafb75c_21_09_02_14_20_04",
Expand Down Expand Up @@ -273,7 +273,7 @@ const withMatchingFilter: ApolloMock<
TaskTestSampleQueryVariables
> = {
request: {
query: GET_TASK_TEST_SAMPLE,
query: TASK_TEST_SAMPLE,
variables: {
tasks: [
"evergreen_lint_lint_model_distro_d4cf298cf0b2536fb3bff875775b93a9ceafb75c_21_09_02_14_20_04",
Expand Down Expand Up @@ -307,7 +307,7 @@ const withNonMatchingFilter: ApolloMock<
TaskTestSampleQueryVariables
> = {
request: {
query: GET_TASK_TEST_SAMPLE,
query: TASK_TEST_SAMPLE,
variables: {
tasks: [
"evergreen_lint_lint_model_distro_d4cf298cf0b2536fb3bff875775b93a9ceafb75c_21_09_02_14_20_04",
Expand Down
4 changes: 2 additions & 2 deletions src/components/HistoryTable/hooks/useTestResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TaskTestSampleQueryVariables,
TaskTestResultSample,
} from "gql/generated/types";
import { GET_TASK_TEST_SAMPLE } from "gql/queries";
import { TASK_TEST_SAMPLE } from "gql/queries";
import { array } from "utils";
import { useHistoryTable } from "../HistoryTableContext";
import { rowType } from "../types";
Expand Down Expand Up @@ -35,7 +35,7 @@ const useTestResults = (rowIndex: number) => {
const { loading } = useQuery<
TaskTestSampleQuery,
TaskTestSampleQueryVariables
>(GET_TASK_TEST_SAMPLE, {
>(TASK_TEST_SAMPLE, {
variables: {
tasks: taskIds,
filters: historyTableFilters,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
UserQuery,
} from "gql/generated/types";
import { SAVE_SUBSCRIPTION } from "gql/mutations";
import { GET_USER } from "gql/queries";
import { USER } from "gql/queries";
import { useUserSettings } from "hooks/useUserSettings";
import { SubscriptionMethodOption } from "types/subscription";
import { Trigger } from "types/triggers";
Expand Down Expand Up @@ -65,7 +65,7 @@ export const NotificationModal: React.FC<NotificationModalProps> = ({
// Fetch user Slack and email information.
const { userSettings } = useUserSettings();
const { slackUsername } = userSettings || {};
const { data: userData } = useQuery<UserQuery>(GET_USER);
const { data: userData } = useQuery<UserQuery>(USER);
const { user } = userData || {};
const { emailAddress } = user || {};

Expand Down
6 changes: 3 additions & 3 deletions src/components/PatchActionButtons/ScheduleTasks/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
UndispatchedTasksQuery,
UndispatchedTasksQueryVariables,
} from "gql/generated/types";
import { GET_UNSCHEDULED_TASKS } from "gql/queries";
import { UNSCHEDULED_TASKS } from "gql/queries";
import { ApolloMock } from "types/gql";

const mocks: ApolloMock<
Expand All @@ -11,7 +11,7 @@ const mocks: ApolloMock<
>[] = [
{
request: {
query: GET_UNSCHEDULED_TASKS,
query: UNSCHEDULED_TASKS,
variables: { versionId: "version" },
},
result: {
Expand Down Expand Up @@ -142,7 +142,7 @@ const mocks: ApolloMock<
},
{
request: {
query: GET_UNSCHEDULED_TASKS,
query: UNSCHEDULED_TASKS,
variables: { versionId: "emptyVersion" },
},
result: {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ProjectSelect/ProjectSelect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ViewableProjectRefsQuery,
ViewableProjectRefsQueryVariables,
} from "gql/generated/types";
import { GET_PROJECTS, GET_VIEWABLE_PROJECTS } from "gql/queries";
import { PROJECTS, VIEWABLE_PROJECTS } from "gql/queries";
import { renderWithRouterMatch, screen, userEvent, waitFor } from "test_utils";
import { ApolloMock } from "types/gql";

Expand Down Expand Up @@ -257,7 +257,7 @@ describe("projectSelect", () => {
const getProjectsMock: [ApolloMock<ProjectsQuery, ProjectsQueryVariables>] = [
{
request: {
query: GET_PROJECTS,
query: PROJECTS,
},
result: {
data: {
Expand Down Expand Up @@ -357,7 +357,7 @@ const getViewableProjectsMock: [
] = [
{
request: {
query: GET_VIEWABLE_PROJECTS,
query: VIEWABLE_PROJECTS,
},
result: {
data: {
Expand Down Expand Up @@ -438,7 +438,7 @@ const noDisabledProjectsMock: [
] = [
{
request: {
query: GET_VIEWABLE_PROJECTS,
query: VIEWABLE_PROJECTS,
},
result: {
data: {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ProjectSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ViewableProjectRefsQuery,
ViewableProjectRefsQueryVariables,
} from "gql/generated/types";
import { GET_PROJECTS, GET_VIEWABLE_PROJECTS } from "gql/queries";
import { PROJECTS, VIEWABLE_PROJECTS } from "gql/queries";
import { Unpacked } from "types/utils";
import { ProjectOptionGroup } from "./ProjectOptionGroup";

Expand All @@ -32,13 +32,13 @@ export const ProjectSelect: React.FC<ProjectSelectProps> = ({
const { data: projectsData, loading: projectsLoading } = useQuery<
ProjectsQuery,
ProjectsQueryVariables
>(GET_PROJECTS, {
>(PROJECTS, {
skip: isProjectSettingsPage,
});

const { data: viewableProjectsData, loading: viewableProjectsLoading } =
useQuery<ViewableProjectRefsQuery, ViewableProjectRefsQueryVariables>(
GET_VIEWABLE_PROJECTS,
VIEWABLE_PROJECTS,
{
skip: !isProjectSettingsPage,
}
Expand Down
Loading

0 comments on commit f10d2b9

Please sign in to comment.