这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
421 changes: 415 additions & 6 deletions console/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"graphiql": "^0.11.11",
"graphiql-explorer-hasura": "0.0.7",
"graphql": "^14.3.0",
"hasura-console-graphiql": "0.0.10",
"graphql-voyager": "^1.0.0-rc.27",
"hasura-console-graphiql": "0.0.11",
"history": "^3.0.0",
"hoist-non-react-statics": "^1.0.3",
"inflection": "^1.12.0",
Expand Down
8 changes: 8 additions & 0 deletions console/src/components/Services/ApiExplorer/ApiExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Helmet from 'react-helmet';

import ApiRequestWrapper from './ApiRequestWrapper';

import globals from '../../../Globals';

/*
import ApiCollectionPanel from './ApiCollectionPanel';

Expand Down Expand Up @@ -64,6 +66,11 @@ class ApiExplorer extends Component {
} = this.props;

const styles = require('./ApiExplorer.scss');
const consoleUrl =
window.location.protocol +
'//' +
window.location.host +
globals.urlPrefix;

return (
<div className={'container-fluid ' + styles.padd_remove}>
Expand All @@ -81,6 +88,7 @@ class ApiExplorer extends Component {
headerFocus={headerFocus}
urlParams={location.query}
serverVersion={serverVersion}
consoleUrl={consoleUrl}
serverConfig={serverConfig}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ ApiRequest.propTypes = {
numberOfTables: PropTypes.number.isRequired,
headerFocus: PropTypes.bool.isRequired,
urlParams: PropTypes.object.isRequired,
consoleUrl: PropTypes.string.isRequired,
};

export default ApiRequest;
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ApiRequestWrapper extends Component {
headerFocus={this.props.headerFocus}
urlParams={this.props.urlParams}
serverVersion={this.props.serverVersion}
consoleUrl={this.props.consoleUrl}
serverConfig={this.props.serverConfig}
/>

Expand All @@ -89,6 +90,7 @@ ApiRequestWrapper.propTypes = {
numberOfTables: PropTypes.number,
headerFocus: PropTypes.bool.isRequired,
urlParams: PropTypes.bool.isRequired,
consoleUrl: PropTypes.string.isRequired,
};

export default ApiRequestWrapper;
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,17 @@
cursor: pointer;
display: inline-block;
margin: 0 5px;
padding: 3px 11px 5px;
padding: 3px 11px 3px;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 150px;
}

.graphiql-container .toolbar-button span i {
margin-left: 5px;
}

.graphiql-container .toolbar-button:active {
background: -webkit-gradient(
linear,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ class GraphiQLWrapper extends Component {
);

const renderGraphiql = graphiqlProps => {
const voyagerUrl = graphqlNetworkData.consoleUrl + '/voyager-view';
return (
<GraphiQL
fetcher={graphQLFetcher}
supportAnalyze
voyagerUrl={voyagerUrl}
analyzeFetcher={analyzeFetcherInstance}
{...graphiqlProps}
/>
Expand Down
2 changes: 1 addition & 1 deletion console/src/components/Services/Metadata/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ export const metadataReducer = (state = defaultState, action) => {
...state,
allowedQueries: [
...state.allowedQueries.map(q =>
(q.name === action.data.queryName ? action.data.newQuery : q)
q.name === action.data.queryName ? action.data.newQuery : q
),
],
};
Expand Down
40 changes: 40 additions & 0 deletions console/src/components/VoyagerView/VoyagerView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { Component } from 'react';
import { GraphQLVoyager } from 'graphql-voyager';
import fetch from 'isomorphic-fetch';
import Endpoints from '../../Endpoints';
import '../../../node_modules/graphql-voyager/dist/voyager.css';
import './voyagerView.css';

class VoyagerView extends Component {
introspectionProvider(query) {
return fetch(Endpoints.graphQLUrl, {
method: 'POST',
headers: this.props.headers,
body: JSON.stringify({ query: query }),
}).then(response => response.json());
}

render() {
return (
<div>
<GraphQLVoyager
introspection={this.introspectionProvider.bind(this)}
workerURI={
'https://cdn.jsdelivr.net/npm/graphql-voyager@1.0.0-rc.27/dist/voyager.worker.min.js'
}
/>
</div>
);
}
}

const generatedVoyagerConnector = connect => {
const mapStateToProps = state => {
return {
headers: state.tables.dataHeaders,
};
};
return connect(mapStateToProps)(VoyagerView);
};

export default generatedVoyagerConnector;
6 changes: 6 additions & 0 deletions console/src/components/VoyagerView/voyagerView.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.graphql-voyager {
height: calc(100vh - 50px);
}
.graphql-voyager .type-doc > .doc-navigation {
padding: 5px 20px 20px 18px;
}
6 changes: 6 additions & 0 deletions console/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import generatedApiExplorer from './components/Services/ApiExplorer/ApiExplorerG

import generatedLoginConnector from './components/Login/Login';

import generatedVoyagerConnector from './components/VoyagerView/VoyagerView';

import metadataContainer from './components/Services/Metadata/Container';
import metadataOptionsContainer from './components/Services/Metadata/MetadataOptions/MetadataOptions';
import metadataStatusContainer from './components/Services/Metadata/MetadataStatus/MetadataStatus';
Expand Down Expand Up @@ -89,6 +91,10 @@ const routes = store => {
>
<Route path="">
<IndexRoute component={generatedApiExplorer(connect)} />
<Route
path="voyager-view"
component={generatedVoyagerConnector(connect)}
/>
<Route
path="api-explorer"
component={generatedApiExplorer(connect)}
Expand Down