Skip to content

Commit

Permalink
Clean up GraphQL implementation and types
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Fernández Gómez committed Dec 18, 2019
1 parent 45ad644 commit 006488d
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 401 deletions.
65 changes: 0 additions & 65 deletions x-pack/legacy/plugins/infra/common/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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}`);
Expand All @@ -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'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,7 +43,7 @@ export const LogEntryFlyout = ({
setTarget,
}: Props) => {
const createFilterHandler = useCallback(
(field: InfraLogItemField) => () => {
(field: LogEntriesItemField) => () => {
const filter = `${field.field}:"${field.value}"`;
setFilter(filter);

Expand Down Expand Up @@ -80,7 +80,7 @@ export const LogEntryFlyout = ({
defaultMessage: 'Value',
}),
sortable: true,
render: (_name: string, item: InfraLogItemField) => (
render: (_name: string, item: LogEntriesItemField) => (
<span>
<EuiToolTip
content={i18n.translate('xpack.infra.logFlyout.setFilterTooltip', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import createContainer from 'constate';
import { isString } from 'lodash';
import React, { useContext, useEffect, useMemo, useState } from 'react';

import { InfraLogItem } from '../../graphql/types';
import { UrlStateContainer } from '../../utils/url_state';
import { useTrackedPromise } from '../../utils/use_tracked_promise';
import { Source } from '../source';
import { fetchLogEntriesItem } from './log_entries/api/fetch_log_entries_item';
import { LogEntriesItem } from '../../../common/http_api';

export enum FlyoutVisibility {
hidden = 'hidden',
Expand All @@ -29,7 +29,7 @@ export const useLogFlyout = () => {
const { sourceId } = useContext(Source.Context);
const [flyoutVisible, setFlyoutVisibility] = useState<boolean>(false);
const [flyoutId, setFlyoutId] = useState<string | null>(null);
const [flyoutItem, setFlyoutItem] = useState<InfraLogItem | null>(null);
const [flyoutItem, setFlyoutItem] = useState<LogEntriesItem | null>(null);
const [surroundingLogsId, setSurroundingLogsId] = useState<string | null>(null);

const [loadFlyoutItemRequest, loadFlyoutItem] = useTrackedPromise(
Expand Down
146 changes: 18 additions & 128 deletions x-pack/legacy/plugins/infra/public/graphql/introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,29 +286,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "logItem",
"description": "",
"args": [
{
"name": "id",
"description": "",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "ID", "ofType": null }
},
"defaultValue": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "OBJECT", "name": "InfraLogItem", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "snapshot",
"description": "A snapshot of nodes",
Expand Down Expand Up @@ -1537,108 +1514,6 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "InfraLogItem",
"description": "",
"fields": [
{
"name": "id",
"description": "The ID of the document",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "ID", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "index",
"description": "The index where the document was found",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "String", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "key",
"description": "Time key for the document - derived from the source configuration timestamp and tiebreaker settings",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "OBJECT", "name": "InfraTimeKey", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "fields",
"description": "An array of flattened fields and values",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "OBJECT", "name": "InfraLogItemField", "ofType": null }
}
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "InfraLogItemField",
"description": "",
"fields": [
{
"name": "field",
"description": "The flattened field name",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "String", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "value",
"description": "The value for the Field as a string",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": { "kind": "SCALAR", "name": "String", "ofType": null }
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "InfraTimerangeInput",
Expand Down Expand Up @@ -1836,9 +1711,24 @@
{ "name": "memory", "description": "", "isDeprecated": false, "deprecationReason": null },
{ "name": "tx", "description": "", "isDeprecated": false, "deprecationReason": null },
{ "name": "rx", "description": "", "isDeprecated": false, "deprecationReason": null },
{ "name": "logRate", "description": "", "isDeprecated": false, "deprecationReason": null },
{ "name": "diskIOReadBytes", "description": "", "isDeprecated": false, "deprecationReason": null },
{ "name": "diskIOWriteBytes", "description": "", "isDeprecated": false, "deprecationReason": null }
{
"name": "logRate",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "diskIOReadBytes",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "diskIOWriteBytes",
"description": "",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
Expand Down
Loading

0 comments on commit 006488d

Please sign in to comment.