diff --git a/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer-enum.js b/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer-enum.js new file mode 100644 index 000000000..e78836406 --- /dev/null +++ b/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer-enum.js @@ -0,0 +1,58 @@ +// @flow +import * as React from 'react'; +import autobind from 'autobind-decorator'; +import MarkdownPreview from '../markdown-preview'; +import type { GraphQLEnumValue } from 'graphql'; +import { GraphQLEnumType } from 'graphql'; + +type Props = {| + type: GraphQLEnumType, +|}; + +@autobind +class GraphQLExplorerEnum extends React.PureComponent { + renderDescription() { + const { type } = this.props; + return ; + } + + renderValues() { + const { type } = this.props; + + const values = type.getValues(); + + return ( + +

Values

+
    + {values.map((value: GraphQLEnumValue) => { + const description = + value.description || + 'This is a long paragraph that is a description for the enum value ' + value.name; + return ( +
  • + {value.name} + {description && ( +
    + +
    + )} +
  • + ); + })} +
+
+ ); + } + + render() { + return ( +
+ {this.renderDescription()} + {this.renderValues()} +
+ ); + } +} + +export default GraphQLExplorerEnum; diff --git a/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer.js b/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer.js index a8d0e0dbb..af9773368 100644 --- a/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer.js +++ b/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer.js @@ -4,21 +4,23 @@ import autobind from 'autobind-decorator'; import GraphQLExplorerField from './graph-ql-explorer-field'; import GraphQLExplorerType from './graph-ql-explorer-type'; import type { GraphQLArgument, GraphQLField, GraphQLSchema, GraphQLType } from 'graphql'; +import { GraphQLEnumType } from 'graphql'; import GraphQLExplorerSchema from './graph-ql-explorer-schema'; +import GraphQLExplorerEnum from './graph-ql-explorer-enum'; type Props = { handleClose: () => void, schema: GraphQLSchema | null, visible: boolean, reference: null | { - type: GraphQLType | null, + type: GraphQLType | GraphQLEnumType | null, argument: GraphQLArgument | null, field: GraphQLField | null, }, }; type HistoryItem = { - currentType: null | GraphQLType, + currentType: null | GraphQLType | GraphQLEnumType, currentField: null | GraphQLField, }; @@ -37,7 +39,7 @@ class GraphQLExplorer extends React.PureComponent { }; } - _handleNavigateType(type: GraphQLType) { + _handleNavigateType(type: GraphQLType | GraphQLEnumType) { this.setState({ currentType: type, currentField: null, @@ -160,6 +162,8 @@ class GraphQLExplorer extends React.PureComponent { child = ( ); + } else if (currentType && currentType instanceof GraphQLEnumType) { + child = ; } else if (currentType) { child = (