Skip to content

Commit

Permalink
[EASI-4080] GrahphQL Conversion (#1021)
Browse files Browse the repository at this point in the history
* Convert GetModelSummary

* Convert ArchiveModelPlan

* convert CreateModelPlan

* Convert GetAllSingleModelPlan and GetAllModelData

* convert CreateModelPlanReply

* Convert GetCurrentUser

* Convert GetFavorites

* Convert GetModelPlan

* Convert GetModelPlanBase

* fixing errors due to conversions

* fixing some type errors

* Convert GetModelPlans

* Covnert GetUserInfo and SerachOktaUser

* Covnert GetUserInfo and SerachOktaUser

* Convert Add and Delete PlanFavorite

* Convert Add and Delete PlanFavorite

* Convert Lock and Unlock TaskListSection

* Convert TaskListSubscriptions and GetTaskListSubscriptions

* temp

* pairing session

* pairing with Patrick

* convert DeleteModelPlanDocuments

* Convert GetModelPlanDocument

* correct document for the test

* update test

* corrected the import statement to fix e2e test
  • Loading branch information
garyjzhao authored Mar 29, 2024
1 parent 90ab77c commit e7f584d
Show file tree
Hide file tree
Showing 81 changed files with 2,471 additions and 372 deletions.
5 changes: 2 additions & 3 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const wp = require('@cypress/webpack-preprocessor');
const apollo = require('@apollo/client');
const fetch = require('cross-fetch'); // needed to allow apollo-client to make queries from Node environment

const LockTaskListSection = require('../../src/queries/TaskListSubscription/LockTaskListSection')
.default;
const { LockTaskListSectionDocument } = require('../../src/gql/gen/graphql');

const cache = new apollo.InMemoryCache();

Expand Down Expand Up @@ -46,7 +45,7 @@ function lockTaskListSection({ euaId, modelPlanID, section }) {
// need to return this Promise to indicate to Cypress that the task was handled
// https://docs.cypress.io/api/commands/task#Usage - "The command will fail if undefined is returned or if the promise is resolved with undefined."
return apolloClient.mutate({
mutation: LockTaskListSection,
mutation: LockTaskListSectionDocument,
variables: input
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/FavoriteCard/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { render } from '@testing-library/react';
import { GetFavorites_modelPlanCollection as FavoritesType } from 'gql/gen/types/GetFavorites';

import { GetFavorites_modelPlanCollection as FavoritesType } from 'queries/types/GetFavorites';
import { ModelStatus, TeamRole } from 'types/graphql-global-types';

import FavoriteCard from './index';
Expand Down
2 changes: 1 addition & 1 deletion src/components/FavoriteCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Card, Grid, Icon, Tag } from '@trussworks/react-uswds';
import classnames from 'classnames';
import { GetFavorites_modelPlanCollection as FavoritesModelType } from 'gql/gen/types/GetFavorites';

import UswdsReactLink from 'components/LinkWrapper';
import Divider from 'components/shared/Divider';
import { GetFavorites_modelPlanCollection as FavoritesModelType } from 'queries/types/GetFavorites';
import { TeamRole } from 'types/graphql-global-types';
import { formatDateUtc } from 'utils/date';
import { UpdateFavoriteProps } from 'views/ModelPlan/ModelPlanOverview';
Expand Down
2 changes: 1 addition & 1 deletion src/components/FavoriteCard/table.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useMemo } from 'react';
import { Row, useFlexLayout, usePagination, useTable } from 'react-table';
import { CardGroup, Table as UswdsTable } from '@trussworks/react-uswds';
import { GetFavorites_modelPlanCollection as FavoritesModelType } from 'gql/gen/types/GetFavorites';

import TablePagination from 'components/TablePagination';
import { GetFavorites_modelPlanCollection as FavoritesModelType } from 'queries/types/GetFavorites';
import { UpdateFavoriteProps } from 'views/ModelPlan/ModelPlanOverview';

import FavoriteCard from '.';
Expand Down
4 changes: 2 additions & 2 deletions src/components/OktaUserSelect/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { MockedProvider } from '@apollo/client/testing';
import { SearchOktaUsersDocument } from 'gql/gen/graphql';

import SearchOktaUsers from 'queries/SearchOktaUsers';
import setup from 'utils/testing/setup';

import OktaUserSelect from './index';
Expand All @@ -10,7 +10,7 @@ describe('OktaUserSelect', () => {
// Cedar contacts query mock
const oktaUsersQuery = {
request: {
query: SearchOktaUsers,
query: SearchOktaUsersDocument,
variables: {
searchTerm: 'Adeline'
}
Expand Down
19 changes: 6 additions & 13 deletions src/components/ShareExport/pdfSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { useQuery } from '@apollo/client';
import { GridContainer, SummaryBox } from '@trussworks/react-uswds';
import classNames from 'classnames';
import { useGetModelSummaryQuery } from 'gql/gen/graphql';
import { GetModelSummary_modelPlan as GetModelSummaryTypes } from 'gql/gen/types/GetModelSummary';
import { useFlags } from 'launchdarkly-react-client-sdk';

import PageHeading from 'components/PageHeading';
import Alert from 'components/shared/Alert';
import GetModelSummary from 'queries/ReadOnly/GetModelSummary';
import {
GetModelSummary as GetModelSummaryType,
GetModelSummary_modelPlan as GetModelSummaryTypes
} from 'queries/ReadOnly/types/GetModelSummary';
import { ModelStatus } from 'types/graphql-global-types';
import { filteredViewOutput } from 'views/ModelPlan/ReadOnly';
import FilterViewBanner from 'views/ModelPlan/ReadOnly/_components/FilterView/Banner';
Expand All @@ -35,14 +31,11 @@ const PDFSummary = ({
modelID: string;
}>();

const { data, loading, error } = useQuery<GetModelSummaryType>(
GetModelSummary,
{
variables: {
id: modelID
}
const { data, loading, error } = useGetModelSummaryQuery({
variables: {
id: modelID
}
);
});

const { abbreviation, modelName, createdDts, modifiedDts, status } =
data?.modelPlan || ({} as GetModelSummaryTypes);
Expand Down
9 changes: 2 additions & 7 deletions src/components/shared/MentionTextArea/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLazyQuery } from '@apollo/client';
import Mention from '@tiptap/extension-mention';
import {
EditorContent,
Expand All @@ -10,12 +9,10 @@ import {
} from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import classNames from 'classnames';
import { TagType } from 'gql/gen/graphql';
import { TagType, useSearchOktaUsersLazyQuery } from 'gql/gen/graphql';
import { sortBy } from 'lodash';

import Alert from 'components/shared/Alert';
import SearchOktaUsers from 'queries/SearchOktaUsers';
import { SearchOktaUsers as SearchOktaUsersType } from 'queries/types/SearchOktaUsers';

import suggestion from './suggestion';
import { formatedSolutionMentions, getMentions } from './util';
Expand Down Expand Up @@ -85,9 +82,7 @@ const MentionTextArea = ({

const [tagAlert, setTagAlert] = useState<boolean>(false);

const [getUsersLazyQuery] = useLazyQuery<SearchOktaUsersType>(
SearchOktaUsers
);
const [getUsersLazyQuery] = useSearchOktaUsersLazyQuery();

const fetchUsers = ({ query }: { query: string }) => {
// If "@" trigger is typed without a following query, return on the solution contacts
Expand Down
12 changes: 6 additions & 6 deletions src/data/mock/general.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import GetFavorites from 'queries/GetFavorites';
import GetModelPlans from 'queries/GetModelPlans';
import { GetFavorites_modelPlanCollection as GetFavoritesType } from 'queries/types/GetFavorites';
import { GetModelPlans_modelPlanCollection as GetModelPlansType } from 'queries/types/GetModelPlans';
import { GetFavoritesDocument, GetModelPlansDocument } from 'gql/gen/graphql';
import { GetFavorites_modelPlanCollection as GetFavoritesType } from 'gql/gen/types/GetFavorites';
import { GetModelPlans_modelPlanCollection as GetModelPlansType } from 'gql/gen/types/GetModelPlans';

import {
ModelCategory,
ModelPlanFilter,
Expand Down Expand Up @@ -68,7 +68,7 @@ export const modelPlanCollectionMock = (
return [
{
request: {
query: GetModelPlans,
query: GetModelPlansDocument,
variables: { filter, isMAC }
},
result: {
Expand Down Expand Up @@ -119,7 +119,7 @@ export const favoritesPlanCollectionMock = (
return [
{
request: {
query: GetFavorites,
query: GetFavoritesDocument,
variables: { filter, isMAC }
},
result: {
Expand Down
6 changes: 3 additions & 3 deletions src/data/mock/readonly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
GetAllPaymentsDocument,
GetAllPaymentsQuery,
GetModelCollaboratorsDocument,
GetModelSummaryDocument,
KeyCharacteristic,
ModelCategory,
ModelLearningSystemType,
Expand Down Expand Up @@ -68,11 +69,10 @@ import {
YesNoType
} from 'gql/gen/graphql';
import { GetModelCollaborators_modelPlan_collaborators as GetModelCollaboratorsType } from 'gql/gen/types/GetModelCollaborators';
import { GetModelSummary_modelPlan as GetModelSummaryTypes } from 'gql/gen/types/GetModelSummary';

import GetOperationalNeeds from 'queries/ITSolutions/GetOperationalNeeds';
import { GetOperationalNeeds as GetOperationalNeedsType } from 'queries/ITSolutions/types/GetOperationalNeeds';
import GetModelSummary from 'queries/ReadOnly/GetModelSummary';
import { GetModelSummary_modelPlan as GetModelSummaryTypes } from 'queries/ReadOnly/types/GetModelSummary';

export const modelID: string = 'f11eb129-2c80-4080-9440-439cbe1a286f';

Expand Down Expand Up @@ -704,7 +704,7 @@ const summaryData: GetModelSummaryTypes = {
export const summaryMock = [
{
request: {
query: GetModelSummary,
query: GetModelSummaryDocument,
variables: { id: modelID }
},
result: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
mutation DeleteModelPlanDocument($id: UUID!) {
deletePlanDocument(id: $id)
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
query GetModelPlanDocument($id: UUID!) {
planDocument(id: $id) {
id
Expand All @@ -18,4 +18,4 @@ export default gql`
createdDts
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
mutation AddPlanFavorite($modelPlanID: UUID!) {
addPlanFavorite(modelPlanID: $modelPlanID) {
modelPlanID
userID
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
mutation DeletePlanFavorite($modelPlanID: UUID!) {
deletePlanFavorite(modelPlanID: $modelPlanID) {
modelPlanID
userID
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
mutation ArchiveModelPlan($id: UUID!, $archived: Boolean!) {
updateModelPlan(id: $id, changes: { archived: $archived }) {
id
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
mutation CreateModelPlan($modelName: String!) {
createModelPlan(modelName: $modelName) {
id
Expand Down Expand Up @@ -48,4 +48,4 @@ export default gql`
}
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
mutation CreateModelPlanReply($input: DiscussionReplyCreateInput!) {
createDiscussionReply(input: $input) {
id
Expand All @@ -12,4 +12,4 @@ export default gql`
createdDts
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';

// This is a query to get ALL data for ALL models, used for exporting/reporting features
export default gql`
export default gql(/* GraphQL */ `
query GetAllModelData {
modelPlanCollection(filter: INCLUDE_ALL) {
id
Expand Down Expand Up @@ -450,4 +450,4 @@ export default gql`
}
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { gql } from '@apollo/client';

// This is a query to get ALL data for a single model, used for exporting/reporting features
export default gql`
export default gql(/* GraphQL */ `
query GetAllSingleModelData($id: UUID!) {
modelPlan(id: $id) {
id
Expand Down Expand Up @@ -449,4 +450,4 @@ export default gql`
}
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
query GetCurrentUser {
currentUser {
launchDarkly {
Expand All @@ -9,4 +9,4 @@ export default gql`
}
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
query GetFavorites($filter: ModelPlanFilter!, $isMAC: Boolean!) {
modelPlanCollection(filter: $filter) {
id
Expand Down Expand Up @@ -30,4 +30,4 @@ export default gql`
}
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
query GetModelPlan($id: UUID!) {
modelPlan(id: $id) {
id
Expand Down Expand Up @@ -112,4 +112,4 @@ export default gql`
}
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
query GetModelPlanBase($id: UUID!) {
modelPlan(id: $id) {
id
Expand All @@ -9,4 +9,4 @@ export default gql`
status
}
}
`;
`);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client';

export default gql`
export default gql(/* GraphQL */ `
query GetModelPlans($filter: ModelPlanFilter!, $isMAC: Boolean!) {
modelPlanCollection(filter: $filter) {
id
Expand Down Expand Up @@ -56,4 +56,4 @@ export default gql`
}
}
}
`;
`);
Loading

0 comments on commit e7f584d

Please sign in to comment.