Moving queries into dedicated files (#1210)
* Moving queries into dedicated files * fix ci
This commit is contained in:
@ -13,7 +13,7 @@ import {
|
||||
useUpdateActivityMutation,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||
|
||||
export type OwnProps = {
|
||||
activity: Pick<Activity, 'id'> & {
|
||||
|
||||
@ -8,7 +8,7 @@ import debounce from 'lodash.debounce';
|
||||
import { BlockEditor } from '@/ui/editor/components/BlockEditor';
|
||||
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
||||
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||
|
||||
const BlockNoteStyledContainer = styled.div`
|
||||
width: 100%;
|
||||
|
||||
@ -13,7 +13,7 @@ import { Activity, useCreateCommentMutation } from '~/generated/graphql';
|
||||
import { isNonEmptyString } from '~/utils/isNonEmptyString';
|
||||
|
||||
import { Comment } from '../comment/Comment';
|
||||
import { GET_ACTIVITY } from '../queries';
|
||||
import { GET_ACTIVITY } from '../graphql/queries/getActivity';
|
||||
import { CommentForDrawer } from '../types/CommentForDrawer';
|
||||
|
||||
type OwnProps = {
|
||||
|
||||
@ -6,7 +6,7 @@ import styled from '@emotion/styled';
|
||||
import { ActivityBodyEditor } from '@/activities/components/ActivityBodyEditor';
|
||||
import { ActivityComments } from '@/activities/components/ActivityComments';
|
||||
import { ActivityTypeDropdown } from '@/activities/components/ActivityTypeDropdown';
|
||||
import { GET_ACTIVITIES } from '@/activities/queries';
|
||||
import { GET_ACTIVITIES } from '@/activities/graphql/queries/getActivities';
|
||||
import { PropertyBox } from '@/ui/editable-field/property-box/components/PropertyBox';
|
||||
import { DateEditableField } from '@/ui/editable-field/variants/components/DateEditableField';
|
||||
import { IconCalendar } from '@/ui/icon/index';
|
||||
@ -22,7 +22,7 @@ import { debounce } from '~/utils/debounce';
|
||||
|
||||
import { ActivityAssigneeEditableField } from '../editable-fields/components/ActivityAssigneeEditableField';
|
||||
import { ActivityRelationEditableField } from '../editable-fields/components/ActivityRelationEditableField';
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||
import { CommentForDrawer } from '../types/CommentForDrawer';
|
||||
|
||||
import { ActivityTitle } from './ActivityTitle';
|
||||
|
||||
@ -2,7 +2,7 @@ import { getOperationName } from '@apollo/client/utilities';
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
import { graphql } from 'msw';
|
||||
|
||||
import { GET_ACTIVITIES } from '@/activities/queries';
|
||||
import { GET_ACTIVITIES } from '@/activities/graphql/queries/getActivities';
|
||||
import { TasksRecoilScopeContext } from '@/activities/states/recoil-scope-contexts/TasksRecoilScopeContext';
|
||||
import { ComponentWithRecoilScopeDecorator } from '~/testing/decorators/ComponentWithRecoilScopeDecorator';
|
||||
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
||||
|
||||
@ -3,8 +3,8 @@ import styled from '@emotion/styled';
|
||||
|
||||
import { useHandleCheckableActivityTargetChange } from '@/activities/hooks/useHandleCheckableActivityTargetChange';
|
||||
import { flatMapAndSortEntityForSelectArrayOfArrayByName } from '@/activities/utils/flatMapAndSortEntityForSelectArrayByName';
|
||||
import { useFilteredSearchCompanyQuery } from '@/companies/queries';
|
||||
import { useFilteredSearchPeopleQuery } from '@/people/queries';
|
||||
import { useFilteredSearchCompanyQuery } from '@/companies/hooks/useFilteredSearchCompanyQuery';
|
||||
import { useFilteredSearchPeopleQuery } from '@/people/hooks/useFilteredSearchPeopleQuery';
|
||||
import { useEditableField } from '@/ui/editable-field/hooks/useEditableField';
|
||||
import { MultipleEntitySelect } from '@/ui/input/relation-picker/components/MultipleEntitySelect';
|
||||
import { Activity, ActivityTarget } from '~/generated/graphql';
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const ACTIVITY_QUERY_FRAGMENT = gql`
|
||||
fragment ActivityQueryFragment on Activity {
|
||||
id
|
||||
createdAt
|
||||
title
|
||||
body
|
||||
type
|
||||
completedAt
|
||||
dueAt
|
||||
assignee {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
displayName
|
||||
avatarUrl
|
||||
}
|
||||
author {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
displayName
|
||||
}
|
||||
comments {
|
||||
id
|
||||
body
|
||||
createdAt
|
||||
updatedAt
|
||||
author {
|
||||
id
|
||||
displayName
|
||||
firstName
|
||||
lastName
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
activityTargets {
|
||||
id
|
||||
companyId
|
||||
personId
|
||||
company {
|
||||
id
|
||||
name
|
||||
domainName
|
||||
}
|
||||
person {
|
||||
id
|
||||
displayName
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,18 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const ACTIVITY_UPDATE_FRAGMENT = gql`
|
||||
fragment ActivityUpdateParts on Activity {
|
||||
id
|
||||
body
|
||||
title
|
||||
type
|
||||
completedAt
|
||||
dueAt
|
||||
assignee {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
displayName
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,24 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const ADD_ACTIVITY_TARGETS = gql`
|
||||
mutation AddActivityTargetsOnActivity(
|
||||
$activityId: String!
|
||||
$activityTargetInputs: [ActivityTargetCreateManyActivityInput!]!
|
||||
) {
|
||||
updateOneActivity(
|
||||
where: { id: $activityId }
|
||||
data: { activityTargets: { createMany: { data: $activityTargetInputs } } }
|
||||
) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
activityTargets {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
companyId
|
||||
personId
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,30 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const CREATE_ACTIVITY_WITH_COMMENT = gql`
|
||||
mutation CreateActivity($data: ActivityCreateInput!) {
|
||||
createOneActivity(data: $data) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
authorId
|
||||
type
|
||||
activityTargets {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
activityId
|
||||
companyId
|
||||
personId
|
||||
}
|
||||
comments {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
body
|
||||
author {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -31,32 +31,3 @@ export const CREATE_COMMENT = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const CREATE_ACTIVITY_WITH_COMMENT = gql`
|
||||
mutation CreateActivity($data: ActivityCreateInput!) {
|
||||
createOneActivity(data: $data) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
authorId
|
||||
type
|
||||
activityTargets {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
activityId
|
||||
companyId
|
||||
personId
|
||||
}
|
||||
comments {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
body
|
||||
author {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,9 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const DELETE_ACTIVITY = gql`
|
||||
mutation DeleteActivity($activityId: String!) {
|
||||
deleteManyActivities(where: { id: { equals: $activityId } }) {
|
||||
count
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,27 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const REMOVE_ACTIVITY_TARGETS = gql`
|
||||
mutation RemoveActivityTargetsOnActivity(
|
||||
$activityId: String!
|
||||
$activityTargetIds: [String!]!
|
||||
) {
|
||||
updateOneActivity(
|
||||
where: { id: $activityId }
|
||||
data: {
|
||||
activityTargets: { deleteMany: { id: { in: $activityTargetIds } } }
|
||||
}
|
||||
) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
activityTargets {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
companyId
|
||||
personId
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
//
|
||||
@ -0,0 +1,12 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const UPDATE_ACTIVITY = gql`
|
||||
mutation UpdateActivity(
|
||||
$where: ActivityWhereUniqueInput!
|
||||
$data: ActivityUpdateInput!
|
||||
) {
|
||||
updateOneActivity(where: $where, data: $data) {
|
||||
...ActivityUpdateParts
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,7 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const UPLOAD_ATTACHMENT = gql`
|
||||
mutation UploadAttachment($file: Upload!, $activityId: String!) {
|
||||
uploadAttachment(file: $file, activityId: $activityId)
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,12 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_ACTIVITIES = gql`
|
||||
query GetActivities(
|
||||
$where: ActivityWhereInput!
|
||||
$orderBy: [ActivityOrderByWithRelationInput!]
|
||||
) {
|
||||
findManyActivities(orderBy: $orderBy, where: $where) {
|
||||
...ActivityQueryFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,24 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_ACTIVITIES_BY_TARGETS = gql`
|
||||
query GetActivitiesByTargets(
|
||||
$activityTargetIds: [String!]!
|
||||
$orderBy: [ActivityOrderByWithRelationInput!]
|
||||
) {
|
||||
findManyActivities(
|
||||
orderBy: $orderBy
|
||||
where: {
|
||||
activityTargets: {
|
||||
some: {
|
||||
OR: [
|
||||
{ personId: { in: $activityTargetIds } }
|
||||
{ companyId: { in: $activityTargetIds } }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
...ActivityQueryFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -0,0 +1,9 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const GET_ACTIVITY = gql`
|
||||
query GetActivity($activityId: String!) {
|
||||
findManyActivities(where: { id: { equals: $activityId } }) {
|
||||
...ActivityQueryFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -3,7 +3,7 @@ import { useApolloClient } from '@apollo/client';
|
||||
|
||||
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
||||
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../queries/update';
|
||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||
|
||||
type Task = Pick<Activity, 'id'>;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { GET_COMPANIES } from '@/companies/queries';
|
||||
import { GET_PEOPLE } from '@/people/queries';
|
||||
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
||||
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
||||
import {
|
||||
Activity,
|
||||
ActivityTarget,
|
||||
@ -10,7 +10,7 @@ import {
|
||||
useRemoveActivityTargetsOnActivityMutation,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { GET_ACTIVITY } from '../queries';
|
||||
import { GET_ACTIVITY } from '../graphql/queries/getActivity';
|
||||
import { ActivityTargetableEntityType } from '../types/ActivityTargetableEntity';
|
||||
import { ActivityTargetableEntityForSelect } from '../types/ActivityTargetableEntityForSelect';
|
||||
|
||||
|
||||
@ -3,19 +3,17 @@ import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { GET_COMPANIES } from '@/companies/queries';
|
||||
import { GET_PEOPLE } from '@/people/queries';
|
||||
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
||||
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
||||
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
|
||||
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
||||
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
||||
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
||||
import { ActivityType, useCreateActivityMutation } from '~/generated/graphql';
|
||||
|
||||
import {
|
||||
GET_ACTIVITIES,
|
||||
GET_ACTIVITIES_BY_TARGETS,
|
||||
GET_ACTIVITY,
|
||||
} from '../queries';
|
||||
import { GET_ACTIVITIES } from '../graphql/queries/getActivities';
|
||||
import { GET_ACTIVITIES_BY_TARGETS } from '../graphql/queries/getActivitiesByTarget';
|
||||
import { GET_ACTIVITY } from '../graphql/queries/getActivity';
|
||||
import { activityTargetableEntityArrayState } from '../states/activityTargetableEntityArrayState';
|
||||
import { viewableActivityIdState } from '../states/viewableActivityIdState';
|
||||
import {
|
||||
|
||||
@ -1 +0,0 @@
|
||||
export * from './select';
|
||||
@ -1,96 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const ACTIVITY_QUERY_FRAGMENT = gql`
|
||||
fragment ActivityQueryFragment on Activity {
|
||||
id
|
||||
createdAt
|
||||
title
|
||||
body
|
||||
type
|
||||
completedAt
|
||||
dueAt
|
||||
assignee {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
displayName
|
||||
avatarUrl
|
||||
}
|
||||
author {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
displayName
|
||||
}
|
||||
comments {
|
||||
id
|
||||
body
|
||||
createdAt
|
||||
updatedAt
|
||||
author {
|
||||
id
|
||||
displayName
|
||||
firstName
|
||||
lastName
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
activityTargets {
|
||||
id
|
||||
companyId
|
||||
personId
|
||||
company {
|
||||
id
|
||||
name
|
||||
domainName
|
||||
}
|
||||
person {
|
||||
id
|
||||
displayName
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_ACTIVITIES_BY_TARGETS = gql`
|
||||
query GetActivitiesByTargets(
|
||||
$activityTargetIds: [String!]!
|
||||
$orderBy: [ActivityOrderByWithRelationInput!]
|
||||
) {
|
||||
findManyActivities(
|
||||
orderBy: $orderBy
|
||||
where: {
|
||||
activityTargets: {
|
||||
some: {
|
||||
OR: [
|
||||
{ personId: { in: $activityTargetIds } }
|
||||
{ companyId: { in: $activityTargetIds } }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
...ActivityQueryFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_ACTIVITIES = gql`
|
||||
query GetActivities(
|
||||
$where: ActivityWhereInput!
|
||||
$orderBy: [ActivityOrderByWithRelationInput!]
|
||||
) {
|
||||
findManyActivities(orderBy: $orderBy, where: $where) {
|
||||
...ActivityQueryFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_ACTIVITY = gql`
|
||||
query GetActivity($activityId: String!) {
|
||||
findManyActivities(where: { id: { equals: $activityId } }) {
|
||||
...ActivityQueryFragment
|
||||
}
|
||||
}
|
||||
`;
|
||||
@ -1,91 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const ADD_ACTIVITY_TARGETS = gql`
|
||||
mutation AddActivityTargetsOnActivity(
|
||||
$activityId: String!
|
||||
$activityTargetInputs: [ActivityTargetCreateManyActivityInput!]!
|
||||
) {
|
||||
updateOneActivity(
|
||||
where: { id: $activityId }
|
||||
data: { activityTargets: { createMany: { data: $activityTargetInputs } } }
|
||||
) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
activityTargets {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
companyId
|
||||
personId
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const REMOVE_ACTIVITY_TARGETS = gql`
|
||||
mutation RemoveActivityTargetsOnActivity(
|
||||
$activityId: String!
|
||||
$activityTargetIds: [String!]!
|
||||
) {
|
||||
updateOneActivity(
|
||||
where: { id: $activityId }
|
||||
data: {
|
||||
activityTargets: { deleteMany: { id: { in: $activityTargetIds } } }
|
||||
}
|
||||
) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
activityTargets {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
companyId
|
||||
personId
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const DELETE_ACTIVITY = gql`
|
||||
mutation DeleteActivity($activityId: String!) {
|
||||
deleteManyActivities(where: { id: { equals: $activityId } }) {
|
||||
count
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const ACTIVITY_UPDATE_FRAGMENT = gql`
|
||||
fragment ActivityUpdateParts on Activity {
|
||||
id
|
||||
body
|
||||
title
|
||||
type
|
||||
completedAt
|
||||
dueAt
|
||||
assignee {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
displayName
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPDATE_ACTIVITY = gql`
|
||||
mutation UpdateActivity(
|
||||
$where: ActivityWhereUniqueInput!
|
||||
$data: ActivityUpdateInput!
|
||||
) {
|
||||
updateOneActivity(where: $where, data: $data) {
|
||||
...ActivityUpdateParts
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const UPLOAD_ATTACHMENT = gql`
|
||||
mutation UploadAttachment($file: Upload!, $activityId: String!) {
|
||||
uploadAttachment(file: $file, activityId: $activityId)
|
||||
}
|
||||
`;
|
||||
@ -3,12 +3,10 @@ import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import {
|
||||
GET_ACTIVITIES,
|
||||
GET_ACTIVITIES_BY_TARGETS,
|
||||
} from '@/activities/queries';
|
||||
import { GET_COMPANIES } from '@/companies/queries';
|
||||
import { GET_PEOPLE } from '@/people/queries';
|
||||
import { GET_ACTIVITIES } from '@/activities/graphql/queries/getActivities';
|
||||
import { GET_ACTIVITIES_BY_TARGETS } from '@/activities/graphql/queries/getActivitiesByTarget';
|
||||
import { GET_COMPANIES } from '@/companies/graphql/queries/getCompanies';
|
||||
import { GET_PEOPLE } from '@/people/graphql/queries/getPeople';
|
||||
import { IconButton } from '@/ui/button/components/IconButton';
|
||||
import { IconTrash } from '@/ui/icon';
|
||||
import { isRightDrawerOpenState } from '@/ui/right-drawer/states/isRightDrawerOpenState';
|
||||
|
||||
Reference in New Issue
Block a user