mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
show indicative comments on graphiql if no tables are present (#120)
This commit is contained in:
parent
45cd97f9b8
commit
87359fb9fc
@ -65,6 +65,7 @@ class ApiExplorer extends Component {
|
||||
wdStyles={wdClass}
|
||||
route={this.props.route}
|
||||
dataHeaders={this.props.dataHeaders}
|
||||
numberOfTables={this.props.tables.length}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -82,6 +83,7 @@ ApiExplorer.propTypes = {
|
||||
displayedApi: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
route: PropTypes.object.isRequired,
|
||||
tables: PropTypes.array.isRequierd,
|
||||
};
|
||||
|
||||
export default ApiExplorer;
|
||||
|
@ -7,6 +7,7 @@ const generatedApiExplorer = connect => {
|
||||
credentials: {},
|
||||
dataApiExplorerData: { ...state.dataApiExplorer },
|
||||
dataHeaders: state.tables.dataHeaders,
|
||||
tables: state.tables.allSchemas,
|
||||
};
|
||||
};
|
||||
return connect(mapStateToProps)(ApiExplorer);
|
||||
|
@ -26,6 +26,19 @@ class ApiRequest extends Component {
|
||||
this.state.tabIndex = 0;
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
console.log(this.props.numberOfTables);
|
||||
if (this.props.numberOfTables !== 0) {
|
||||
const graphqlQueryInLS = window.localStorage.getItem('graphiql:query');
|
||||
console.log(graphqlQueryInLS);
|
||||
if (graphqlQueryInLS && graphqlQueryInLS.indexOf('do not have') !== -1) {
|
||||
console.log('Clearing');
|
||||
window.localStorage.removeItem('graphiql:query');
|
||||
console.log('Cleared');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onGenerateApiCodeClicked = () => {
|
||||
this.props.dispatch(generateApiCodeClicked());
|
||||
};
|
||||
@ -308,7 +321,12 @@ class ApiRequest extends Component {
|
||||
getValidBody() {
|
||||
switch (this.props.bodyType) {
|
||||
case 'graphql':
|
||||
return <GraphiQLWrapper data={this.props} />;
|
||||
return (
|
||||
<GraphiQLWrapper
|
||||
data={this.props}
|
||||
numberOfTables={this.props.numberOfTables}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
@ -343,6 +361,7 @@ ApiRequest.propTypes = {
|
||||
credentials: PropTypes.object.isRequired,
|
||||
bodyType: PropTypes.string.isRequired,
|
||||
route: PropTypes.object.isRequired,
|
||||
numberOfTables: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
export default ApiRequest;
|
||||
|
@ -38,6 +38,7 @@ class ApiRequestWrapper extends Component {
|
||||
explorerData={this.props.explorerData}
|
||||
dispatch={this.props.dispatch}
|
||||
dataHeaders={this.props.dataHeaders}
|
||||
numberOfTables={this.props.numberOfTables}
|
||||
/>
|
||||
{this.props.request.bodyType !== 'graphql' ? (
|
||||
<ApiResponse
|
||||
@ -66,6 +67,7 @@ ApiRequestWrapper.propTypes = {
|
||||
requestStyles: PropTypes.string,
|
||||
wdStyles: PropTypes.string,
|
||||
dispatch: PropTypes.func,
|
||||
numberOfTables: PropTypes.number,
|
||||
};
|
||||
|
||||
export default ApiRequestWrapper;
|
||||
|
@ -23,6 +23,7 @@ class GraphiQLWrapper extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log(this.props.numberOfTables);
|
||||
const styles = require('../Common/Common.scss');
|
||||
|
||||
const graphqlUrl = this.props.data.url;
|
||||
@ -40,15 +41,9 @@ class GraphiQLWrapper extends Component {
|
||||
<i className={'fa fa-spinner fa-spin ' + styles.graphSpinner} />
|
||||
);
|
||||
|
||||
if (!this.state.error && !this.state.noSchema) {
|
||||
content = (
|
||||
<GraphiQL
|
||||
fetcher={graphQLFetcher}
|
||||
defaultQuery={''}
|
||||
schema={undefined}
|
||||
/>
|
||||
);
|
||||
} else if (this.state.noSchema) {
|
||||
if (!this.state.error && this.props.numberOfTables !== 0) {
|
||||
content = <GraphiQL fetcher={graphQLFetcher} />;
|
||||
} else if (this.props.numberOfTables === 0) {
|
||||
content = (
|
||||
<GraphiQL
|
||||
fetcher={graphQLFetcher}
|
||||
@ -83,6 +78,7 @@ class GraphiQLWrapper extends Component {
|
||||
GraphiQLWrapper.propTypes = {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
data: PropTypes.object.isRequired,
|
||||
numberOfTables: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
export default GraphiQLWrapper;
|
||||
|
@ -36,7 +36,13 @@ const editItem = (tableName, colValues) => {
|
||||
} else if (Reals.indexOf(colSchema.data_type) > 0) {
|
||||
insertObject[colName] = parseFloat(colValues[colName], 10);
|
||||
} else if (colSchema.data_type === 'boolean') {
|
||||
insertObject[colName] = colValues[colName] === 'true' ? true : false;
|
||||
if (colValues[colName] === 'true') {
|
||||
insertObject[colName] = true;
|
||||
} else if (colValues[colName] === 'false') {
|
||||
insertObject[colName] = false;
|
||||
} else {
|
||||
insertObject[colName] = null;
|
||||
}
|
||||
} else if (colType === 'json' || colType === 'jsonb') {
|
||||
try {
|
||||
const val = JSON.parse(colValues[colName]);
|
||||
|
@ -313,6 +313,7 @@ class EditItem extends Component {
|
||||
} else {
|
||||
inputValues[colName] = refs[colName].valueNode.value; // TypedInput is an input inside a div
|
||||
}
|
||||
console.log(inputValues[colName]);
|
||||
});
|
||||
dispatch(editItem(tableName, inputValues));
|
||||
}}
|
||||
|
@ -41,7 +41,13 @@ const insertItem = (tableName, colValues) => {
|
||||
insertObject[colName] =
|
||||
parseFloat(colValues[colName], 10) || colValues[colName];
|
||||
} else if (colType === 'boolean') {
|
||||
insertObject[colName] = colValues[colName] === 'true' ? true : false;
|
||||
if (colValues[colName] === 'true') {
|
||||
insertObject[colName] = true;
|
||||
} else if (colValues[colName] === 'false') {
|
||||
insertObject[colName] = false;
|
||||
} else {
|
||||
insertObject[colName] = null;
|
||||
}
|
||||
} else if (colType === 'json' || colType === 'jsonb') {
|
||||
try {
|
||||
const val = JSON.parse(colValues[colName]);
|
||||
|
Loading…
Reference in New Issue
Block a user