mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Merge branch 'pull/1880' into develop
This commit is contained in:
commit
6d259ed067
@ -4,6 +4,7 @@ import GraphQLExplorerTypeLink from './graph-ql-explorer-type-link';
|
|||||||
import autobind from 'autobind-decorator';
|
import autobind from 'autobind-decorator';
|
||||||
import MarkdownPreview from '../markdown-preview';
|
import MarkdownPreview from '../markdown-preview';
|
||||||
import GraphQLExplorerFieldLink from './graph-ql-explorer-field-link';
|
import GraphQLExplorerFieldLink from './graph-ql-explorer-field-link';
|
||||||
|
import { GraphQLUnionType } from 'graphql';
|
||||||
import type { GraphQLType, GraphQLField } from 'graphql';
|
import type { GraphQLType, GraphQLField } from 'graphql';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -29,6 +30,34 @@ class GraphQLExplorerType extends React.PureComponent<Props> {
|
|||||||
return <MarkdownPreview markdown={type.description || '*no description*'} />;
|
return <MarkdownPreview markdown={type.description || '*no description*'} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 (
|
||||||
|
<React.Fragment>
|
||||||
|
<h2 className="graphql-explorer__subheading">Possible Types</h2>
|
||||||
|
<ul className="graphql-explorer__defs">
|
||||||
|
{types.map(type => (
|
||||||
|
<li key={type.name}>
|
||||||
|
<GraphQLExplorerTypeLink onNavigate={onNavigateType} type={type} />
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
renderFieldsMaybe() {
|
renderFieldsMaybe() {
|
||||||
const { type, onNavigateType } = this.props;
|
const { type, onNavigateType } = this.props;
|
||||||
if (typeof type.getFields !== 'function') {
|
if (typeof type.getFields !== 'function') {
|
||||||
@ -92,6 +121,7 @@ class GraphQLExplorerType extends React.PureComponent<Props> {
|
|||||||
return (
|
return (
|
||||||
<div className="graphql-explorer__type">
|
<div className="graphql-explorer__type">
|
||||||
{this.renderDescription()}
|
{this.renderDescription()}
|
||||||
|
{this.renderTypesMaybe()}
|
||||||
{this.renderFieldsMaybe()}
|
{this.renderFieldsMaybe()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user