diff --git a/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer-type.js b/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer-type.js index f092555d9..c202e8731 100644 --- a/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer-type.js +++ b/packages/insomnia-app/app/ui/components/graph-ql-explorer/graph-ql-explorer-type.js @@ -4,6 +4,7 @@ import GraphQLExplorerTypeLink from './graph-ql-explorer-type-link'; import autobind from 'autobind-decorator'; import MarkdownPreview from '../markdown-preview'; import GraphQLExplorerFieldLink from './graph-ql-explorer-field-link'; +import { GraphQLUnionType } from 'graphql'; import type { GraphQLType, GraphQLField } from 'graphql'; type Props = { @@ -29,6 +30,34 @@ class GraphQLExplorerType extends React.PureComponent { return ; } + renderTypesMaybe() { + const { type, onNavigateType } = this.props; + + if (typeof type.getTypes !== 'function') { + return null; + } + + if (!(type instanceof GraphQLUnionType)) { + return null; + } + + const types = (type: Object).getTypes(); + + console.log('UNION TYPE? ', types); + return ( + +

Possible Types

+
    + {types.map(type => ( +
  • + +
  • + ))} +
+
+ ); + } + renderFieldsMaybe() { const { type, onNavigateType } = this.props; if (typeof type.getFields !== 'function') { @@ -92,6 +121,7 @@ class GraphQLExplorerType extends React.PureComponent { return (
{this.renderDescription()} + {this.renderTypesMaybe()} {this.renderFieldsMaybe()}
);