@@ -3,6 +3,9 @@ var cloneDeep = require('lodash.clonedeep');
33const MongoClient = require ( 'mongodb' ) . MongoClient ;
44var pluralize = require ( 'pluralize' ) ;
55const { ipcMain } = require ( 'electron' )
6+ const { graphqlHTTP } = require ( 'express-graphql' ) ;
7+ const express = require ( 'express' ) ;
8+ const app = express ( ) ;
69
710const {
811 GraphQLObjectType,
@@ -28,7 +31,7 @@ function addWhiteSpace(number) {
2831ipcMain . on ( 'selectedSchemas' , ( event , arg ) => {
2932 const url = arg . uriId ;
3033 const data = arg . selectedSchemas ;
31- console . log ( data ) ;
34+ console . log ( 'IS THIS IT????' , data ) ;
3235 // Function for capitalization
3336 const capitalize = ( s ) => {
3437 if ( typeof s !== 'string' ) return '' ;
@@ -143,7 +146,6 @@ ipcMain.on('selectedSchemas', (event, arg) => {
143146 const client = new MongoClient ( url , { useUnifiedTopology : true } ) ;
144147 const regex = / \/ ( \w + ) \? / g;
145148 const databaseName = url . match ( regex ) ;
146- console . log ( 'DATABASSSSUUUUUU' , url ) ;
147149 const databaseString = databaseName
148150 . join ( '' )
149151 . slice ( 1 , databaseName . join ( '' ) . length - 1 ) ;
@@ -204,7 +206,6 @@ ipcMain.on('selectedSchemas', (event, arg) => {
204206 . forEach ( ( el ) => {
205207 listOfProperties += `${ el } : args.${ el } ,|${ addWhiteSpace ( 10 ) } ` ;
206208 } ) ;
207- // console.log('LIST OF PROPERTIESSSSSSSSSSSS===============', listOfProperties)
208209
209210 mutationObjStr +=
210211 ` add${ capitalize ( property ) } : {|` +
@@ -278,6 +279,15 @@ ipcMain.on('selectedSchemas', (event, arg) => {
278279 fields : rootQueryObj ,
279280 } ) ;
280281
282+ const Schema = new GraphQLSchema ( {
283+ query : RootQuery ,
284+ } )
285+
286+ app . use (
287+ '/graphql' ,
288+ graphqlHTTP ( { schema : Schema , graphiql : true } )
289+ ) ;
290+
281291 event . sender . send ( "returnedSchemas" , { types : stringObj , queries : sendRootQueryObj , mutations : mutationSchema , mongoSchema : buildMongoStr } )
282292} )
283293
@@ -286,6 +296,8 @@ const RootQuery = new GraphQLObjectType({
286296 fields : rootQueryObj ,
287297} ) ;
288298
299+ app . listen ( 3000 , ( ) => console . log ( 'listening on port 3000' ) ) ;
300+
289301module . exports = {
290302 converter,
291303 schema : new GraphQLSchema ( {
0 commit comments