Эх сурвалжийг харах

修改 description 传值,修复因 update_schema 未返回 id 导致的 error 问题

xy 7 жил өмнө
parent
commit
2a7ad396d5

+ 12 - 9
src/components/common/schema/change/SchemaChange.jsx

@@ -17,8 +17,8 @@ class SchemaChange extends Component {
             columns: props.columns,
             newColName: '',
             newColType: 'type',
-            types: ['ID', 'String', 'Int', 'Float'],
-            descriptions: ['description', 'key', 'non-null', 'non-null-list']
+            types: ['ID', 'String', 'Int', 'Float','Boolean', 'DateTime'],
+            descriptions: ['description', 'key', 'non-null', 'non-null-list', 'list']
         }
     }
 
@@ -227,11 +227,6 @@ class UpdateTableButton extends Component {
 
                                     data.schema_by_id = update_schema;
 
-                                    if (update_schema === null) {
-                                        console.log('你是否忘记了修改 Schenma 组件中的 this.state.schemaID? ');
-                                        console.log('所以报错 : TypeError: Cannot read property "schemaName" of null');
-                                    }
-
                                     let showSchemaData = cache.readQuery({
                                         query: SHOW_SCHEMA,
                                         variables: {user_id: userID}
@@ -267,10 +262,19 @@ class UpdateTableButton extends Component {
                                     let schemaCols;
                                     if (schemaData.schema_by_id === null) schemaCols = [];
                                     else schemaCols = JSON.parse(schemaData.schema_by_id.schemaData);
+
+                                    // 处理一下description的问题
+                                    let cols = this.props.columns;
+                                    cols.map(obj=> {
+                                        if (obj.description === 'description')
+                                            obj.description = '';
+                                        return obj
+                                    });
+
                                     let newTable = {
                                         name: this.props.currentTable,
                                         remark: this.props.remark,
-                                        cols: this.props.columns
+                                        cols
                                     };
 
                                     const index = this.props.currentTableIndex;
@@ -301,7 +305,6 @@ class UpdateTableButton extends Component {
                         )
                     }
                 }
-
             </Query>
         )
     }

+ 1 - 0
src/components/common/schema/gql.js

@@ -43,6 +43,7 @@ const UPDATE_SCHEMA = gql`
                 ) {
                     schemaName,
                     schemaData
+                    id
                 }
             }
         `;

+ 1 - 1
src/index.js

@@ -19,7 +19,7 @@ addLocaleData([...en,...zh]);
 
 const client = new ApolloClient({
   // uri: "http://service-eucrnpse-1254337200.ap-guangzhou.apigateway.myqcloud.com/release/graphql"
-  uri: "http://localhost:4000/graphql"
+  uri: "http://localhost:3000/graphql"
 });
 
 let browserLanguage = (navigator.language || navigator.browserLanguage).toLowerCase().split('-')[0];