From 006488d59faea83925f2c04f41a18fbf446d2c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20G=C3=B3mez?= Date: Wed, 18 Dec 2019 15:34:30 +0100 Subject: [PATCH] Clean up GraphQL implementation and types --- .../plugins/infra/common/graphql/types.ts | 65 -------- .../log_entry_actions_menu.tsx | 8 +- .../log_entry_flyout/log_entry_flyout.tsx | 8 +- .../public/containers/logs/log_flyout.tsx | 4 +- .../infra/public/graphql/introspection.json | 146 +++--------------- .../plugins/infra/public/graphql/types.ts | 65 -------- .../server/graphql/log_entries/resolvers.ts | 22 --- .../server/graphql/log_entries/schema.gql.ts | 19 --- .../plugins/infra/server/graphql/types.ts | 88 +---------- ...vert_document_source_to_log_item_fields.ts | 6 +- .../log_entries_domain/log_entries_domain.ts | 5 +- 11 files changed, 35 insertions(+), 401 deletions(-) diff --git a/x-pack/legacy/plugins/infra/common/graphql/types.ts b/x-pack/legacy/plugins/infra/common/graphql/types.ts index bd1d3945f35f7..bb089bf8bf8ad 100644 --- a/x-pack/legacy/plugins/infra/common/graphql/types.ts +++ b/x-pack/legacy/plugins/infra/common/graphql/types.ts @@ -35,7 +35,6 @@ export interface InfraSource { /** Sequences of log entries matching sets of highlighting queries within an interval */ logEntryHighlights: InfraLogEntryInterval[]; - logItem: InfraLogItem; /** A snapshot of nodes */ snapshot?: InfraSnapshotResponse | null; @@ -205,24 +204,6 @@ export interface InfraLogEntryFieldColumn { highlights: string[]; } -export interface InfraLogItem { - /** The ID of the document */ - id: string; - /** The index where the document was found */ - index: string; - /** Time key for the document - derived from the source configuration timestamp and tiebreaker settings */ - key: InfraTimeKey; - /** An array of flattened fields and values */ - fields: InfraLogItemField[]; -} - -export interface InfraLogItemField { - /** The flattened field name */ - field: string; - /** The value for the Field as a string */ - value: string; -} - export interface InfraSnapshotResponse { /** Nodes of type host, container or pod grouped by 0, 1 or 2 terms */ nodes: InfraSnapshotNode[]; @@ -424,9 +405,6 @@ export interface LogEntryHighlightsInfraSourceArgs { /** The highlighting to apply to the log entries */ highlights: InfraLogEntryHighlightInput[]; } -export interface LogItemInfraSourceArgs { - id: string; -} export interface SnapshotInfraSourceArgs { timerange: InfraTimerangeInput; @@ -600,49 +578,6 @@ export type InfraLogMessageSegment = InfraLogMessageFieldSegment | InfraLogMessa // Documents // ==================================================== -export namespace FlyoutItemQuery { - export type Variables = { - sourceId: string; - itemId: string; - }; - - export type Query = { - __typename?: 'Query'; - - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - - id: string; - - logItem: LogItem; - }; - - export type LogItem = { - __typename?: 'InfraLogItem'; - - id: string; - - index: string; - - key: Key; - - fields: Fields[]; - }; - - export type Key = InfraTimeKeyFields.Fragment; - - export type Fields = { - __typename?: 'InfraLogItemField'; - - field: string; - - value: string; - }; -} - export namespace LogEntryHighlightsQuery { export type Variables = { sourceId?: string | null; diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx index 0d20e7b733dfa..2af754dde208f 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx +++ b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_actions_menu.tsx @@ -10,14 +10,14 @@ import React, { useMemo } from 'react'; import url from 'url'; import chrome from 'ui/chrome'; -import { InfraLogItem } from '../../../graphql/types'; import { useVisibilityState } from '../../../utils/use_visibility_state'; import { getTraceUrl } from '../../../../../apm/public/components/shared/Links/apm/ExternalLinks'; +import { LogEntriesItem } from '../../../../common/http_api'; const UPTIME_FIELDS = ['container.id', 'host.ip', 'kubernetes.pod.uid']; export const LogEntryActionsMenu: React.FunctionComponent<{ - logItem: InfraLogItem; + logItem: LogEntriesItem; }> = ({ logItem }) => { const { hide, isVisible, show } = useVisibilityState(false); @@ -84,7 +84,7 @@ export const LogEntryActionsMenu: React.FunctionComponent<{ ); }; -const getUptimeLink = (logItem: InfraLogItem) => { +const getUptimeLink = (logItem: LogEntriesItem) => { const searchExpressions = logItem.fields .filter(({ field, value }) => value != null && UPTIME_FIELDS.includes(field)) .map(({ field, value }) => `${field}:${value}`); @@ -99,7 +99,7 @@ const getUptimeLink = (logItem: InfraLogItem) => { }); }; -const getAPMLink = (logItem: InfraLogItem) => { +const getAPMLink = (logItem: LogEntriesItem) => { const traceIdEntry = logItem.fields.find( ({ field, value }) => value != null && field === 'trace.id' ); diff --git a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx index ed61c70afb73f..d2cb9cf9370dd 100644 --- a/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx +++ b/x-pack/legacy/plugins/infra/public/components/logging/log_entry_flyout/log_entry_flyout.tsx @@ -22,12 +22,12 @@ import React, { useCallback, useMemo } from 'react'; import euiStyled from '../../../../../../common/eui_styled_components'; import { TimeKey } from '../../../../common/time'; -import { InfraLogItem, InfraLogItemField } from '../../../graphql/types'; import { InfraLoadingPanel } from '../../loading'; import { LogEntryActionsMenu } from './log_entry_actions_menu'; +import { LogEntriesItem, LogEntriesItemField } from '../../../../common/http_api'; interface Props { - flyoutItem: InfraLogItem | null; + flyoutItem: LogEntriesItem | null; setFlyoutVisibility: (visible: boolean) => void; setFilter: (filter: string) => void; setTarget: (timeKey: TimeKey, flyoutItemId: string) => void; @@ -43,7 +43,7 @@ export const LogEntryFlyout = ({ setTarget, }: Props) => { const createFilterHandler = useCallback( - (field: InfraLogItemField) => () => { + (field: LogEntriesItemField) => () => { const filter = `${field.field}:"${field.value}"`; setFilter(filter); @@ -80,7 +80,7 @@ export const LogEntryFlyout = ({ defaultMessage: 'Value', }), sortable: true, - render: (_name: string, item: InfraLogItemField) => ( + render: (_name: string, item: LogEntriesItemField) => (