diff --git a/.prettierrc.json b/.prettierrc.json
index a241d4d..2125623 100644
--- a/.prettierrc.json
+++ b/.prettierrc.json
@@ -1,13 +1,15 @@
{
- "trailingComma": "es5",
+ "trailingComma": "none",
"tabWidth": 2,
- "semi": true,
+ "semi": false,
"singleQuote": true,
- "printWidth": 160,
+ "printWidth": 100,
"jsxSingleQuote": true,
"useTabs": false,
"useEditorConfig": true,
"htmlWhitespaceSensitivity": "css",
+ "bracketSameLine": true,
"bracketSpacing": true,
- "prettier.arrowParens": "always"
+ "arrowParens": "always",
+ "quoteProps": "as-needed"
}
diff --git a/__tests__/supertest.js b/__tests__/supertest.js
index c7652cf..a6dd2c1 100644
--- a/__tests__/supertest.js
+++ b/__tests__/supertest.js
@@ -1,53 +1,48 @@
-const request = require('supertest');
-
-
-
-const server = 'http://localhost:8080';
-
-describe('Route integration', function(){
- describe('/', () => {
- describe('GET', () => {
- it('responds with 200 status and text/html content type', function(done){
- request(server)
- .get('/convert-demo-db')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(200, done);
- });
- });
-
-
- describe('POST', () => {
- it('responds with 200 status and text/html content type', function(done){
- request(server)
- .get('/convert-sql-db')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(200, done);
- });
- });
+const request = require('supertest')
+
+const server = 'http://localhost:8080'
+
+describe('Route integration', function () {
+ describe('/', () => {
+ describe('GET', () => {
+ it('responds with 200 status and text/html content type', function (done) {
+ request(server)
+ .get('/convert-demo-db')
+ .set('Accept', 'application/json')
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ })
+ })
- describe('POST', () => {
- it('responds with 200 status and text/html content type', function(done){
- request(server)
- .get('/convert-mongo-db')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(200, done);
- });
- });
+ describe('POST', () => {
+ it('responds with 200 status and text/html content type', function (done) {
+ request(server)
+ .get('/convert-sql-db')
+ .set('Accept', 'application/json')
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ })
+ })
+ describe('POST', () => {
+ it('responds with 200 status and text/html content type', function (done) {
+ request(server)
+ .get('/convert-mongo-db')
+ .set('Accept', 'application/json')
+ .expect('Content-Type', /json/)
+ .expect(200, done)
+ })
})
- describe('/', () => {
- describe('GET', () => {
- it('responds with 404 not found', function(done){
- request(server)
- .get('/fake')
- .set('Accept', 'application/json')
- .expect('Content-Type', /json/)
- .expect(404, done);
- });
- });
+ })
+ describe('/', () => {
+ describe('GET', () => {
+ it('responds with 404 not found', function (done) {
+ request(server)
+ .get('/fake')
+ .set('Accept', 'application/json')
+ .expect('Content-Type', /json/)
+ .expect(404, done)
+ })
})
-});
-
+ })
+})
diff --git a/components/CodeBoxContainer.js b/components/CodeBoxContainer.js
index 4800cdc..f09fe60 100644
--- a/components/CodeBoxContainer.js
+++ b/components/CodeBoxContainer.js
@@ -1,50 +1,50 @@
-import React from 'react';
-import { saveAs } from 'file-saver';
-import { useSelector } from 'react-redux';
-import SyntaxHighlighter from 'react-syntax-highlighter';
-import { Button } from '@nextui-org/react';
+import React from 'react'
+import { saveAs } from 'file-saver'
+import { useSelector } from 'react-redux'
+import SyntaxHighlighter from 'react-syntax-highlighter'
+import { Button } from '@nextui-org/react'
-import qtCreator from '../node_modules/react-syntax-highlighter/dist/esm/styles/hljs/qtcreator_dark';
-import styles from '../styles/CodeBoxContainer.module.css';
-import { SampleGQLServerCode, SampleGQLClientQueriesCode, SampleGQLClientMutationsCode } from '../server/sampleDB';
+import qtCreator from '../node_modules/react-syntax-highlighter/dist/esm/styles/hljs/qtcreator_dark'
+import styles from '../styles/CodeBoxContainer.module.css'
+import { SampleGQLServerCode, SampleGQLClientQueriesCode, SampleGQLClientMutationsCode } from '../server/sampleDB'
function CodeBoxContainer() {
- const showDemo = useSelector((state) => state.demo.showDemo);
- const data = useSelector((state) => state.demo.queries);
+ const showDemo = useSelector((state) => state.demo.showDemo)
+ const data = useSelector((state) => state.demo.queries)
- const uriDataGQLServerCode = data ? data.GQLServerCode : '';
- const uriDataGQLClientMutationsCode = data ? data.GQLClientMutationsCode : '';
- const uriDataGQLClientQueriesCode = data ? data.GQLClientQueriesCode : '';
+ const uriDataGQLServerCode = data ? data.GQLServerCode : ''
+ const uriDataGQLClientMutationsCode = data ? data.GQLClientMutationsCode : ''
+ const uriDataGQLClientQueriesCode = data ? data.GQLClientQueriesCode : ''
/* EXPORT GQL SERVER CODE */
const exportGQLServerCode = () => {
if (showDemo) {
- saveAs(new File([`${SampleGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' }));
+ saveAs(new File([`${SampleGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' }))
}
if (!showDemo && uriDataGQLServerCode !== '') {
- saveAs(new File([`${uriDataGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' }));
+ saveAs(new File([`${uriDataGQLServerCode}`], 'GQLServerCode.js', { type: 'text/plain;charset=utf-8' }))
}
- };
+ }
/* EXPORT GQL CLIENT MUTATIONS CODE */
const exportGQLClientMutationsCode = () => {
if (showDemo) {
- saveAs(new File([`${SampleGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' }));
+ saveAs(new File([`${SampleGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' }))
}
if (!showDemo && uriDataGQLClientMutationsCode !== '') {
- saveAs(new File([`${uriDataGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' }));
+ saveAs(new File([`${uriDataGQLClientMutationsCode}`], 'GQLClientMutationsCode.js', { type: 'text/plain;charset=utf-8' }))
}
- };
+ }
/* EXPORT GQL CLIENT QUERIES CODE */
const exportGQLClientQueriesCode = () => {
if (showDemo) {
- saveAs(new File([`${SampleGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' }));
+ saveAs(new File([`${SampleGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' }))
}
if (!showDemo && uriDataGQLClientQueriesCode !== '') {
- saveAs(new File([`${uriDataGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' }));
+ saveAs(new File([`${uriDataGQLClientQueriesCode}`], 'GQLClientQueriesCode.js', { type: 'text/plain;charset=utf-8' }))
}
- };
+ }
return (
@@ -60,7 +60,7 @@ function CodeBoxContainer() {
size='sm'
css={{ px: '$4', height: '$10' }}
onClick={() => {
- exportGQLClientMutationsCode();
+ exportGQLClientMutationsCode()
}}
>
Export Code
@@ -81,7 +81,7 @@ function CodeBoxContainer() {
size='sm'
css={{ px: '$4', height: '$10' }}
onClick={() => {
- exportGQLClientQueriesCode();
+ exportGQLClientQueriesCode()
}}
>
Export Code
@@ -103,7 +103,7 @@ function CodeBoxContainer() {
size='sm'
css={{ px: '$4', height: '$10' }}
onClick={() => {
- exportGQLServerCode();
+ exportGQLServerCode()
}}
>
Export Code
@@ -114,7 +114,7 @@ function CodeBoxContainer() {
- );
+ )
}
-export default CodeBoxContainer;
+export default CodeBoxContainer
diff --git a/components/DbInfo.js b/components/DbInfo.js
index 6fd51e8..41cc3f0 100644
--- a/components/DbInfo.js
+++ b/components/DbInfo.js
@@ -1,15 +1,21 @@
-import React, { useState } from 'react';
-import { Button, Spacer } from '@nextui-org/react';
-import { useDispatch, useSelector } from 'react-redux';
+import React, { useState } from 'react'
+import { Button, Spacer } from '@nextui-org/react'
+import { useDispatch, useSelector } from 'react-redux'
-import { setQueries, showDemo, setIsError, setShowDBInfo, setShowFlowModal } from '../features/demoSlice';
-import styles from '../styles/DbInfo.module.css';
+import {
+ setQueries,
+ showDemo,
+ setIsError,
+ setShowDBInfo,
+ setShowFlowModal
+} from '../features/demoSlice'
+import styles from '../styles/DbInfo.module.css'
function DbInfo({ dbData, hidePanel, setDbData }) {
- const [dbName, setDBName] = useState(!dbData ? 'Sample Database' : dbData.name);
- const [dbType, setDBType] = useState(!dbData ? 'PostgreSQL' : dbData.type);
+ const [dbName, setDBName] = useState(!dbData ? 'Sample Database' : dbData.name)
+ const [dbType, setDBType] = useState(!dbData ? 'PostgreSQL' : dbData.type)
- const dispatch = useDispatch();
+ const dispatch = useDispatch()
return (
@@ -21,17 +27,16 @@ function DbInfo({ dbData, hidePanel, setDbData }) {
{
- dispatch(setQueries(''));
- dispatch(showDemo(false));
- dispatch(setIsError(false));
- dispatch(setShowDBInfo(false));
- setDbData(null);
- }}
- >
+ dispatch(setQueries(''))
+ dispatch(showDemo(false))
+ dispatch(setIsError(false))
+ dispatch(setShowDBInfo(false))
+ setDbData(null)
+ }}>
Reset
- );
+ )
}
-export default DbInfo;
+export default DbInfo
diff --git a/components/DbInput.js b/components/DbInput.js
index 061f84f..783bfa3 100644
--- a/components/DbInput.js
+++ b/components/DbInput.js
@@ -1,45 +1,52 @@
-import React, { useRef } from 'react';
-import { Input, Spacer, Button } from '@nextui-org/react';
-import { useDispatch, useSelector } from 'react-redux';
-import CryptoJS from 'crypto-js';
+import React, { useRef } from 'react'
+import { Input, Spacer, Button } from '@nextui-org/react'
+import { useDispatch, useSelector } from 'react-redux'
+import CryptoJS from 'crypto-js'
-import { setQueries, showDemo, setIsError, setErrorMsg, setShowLoader, setShowDBInfo } from '../features/demoSlice';
-import styles from '../styles/DbUri.module.css';
-import secretKey from '../server/secretKey';
+import {
+ setQueries,
+ showDemo,
+ setIsError,
+ setErrorMsg,
+ setShowLoader,
+ setShowDBInfo
+} from '../features/demoSlice'
+import styles from '../styles/DbUri.module.css'
+import secretKey from '../server/secretKey'
function DbInput({ fetchData }) {
- const uriField = useRef();
- const isError = useSelector((state) => state.demo.isError);
- const errorMsg = useSelector((state) => state.demo.errorMsg);
- const dispatch = useDispatch();
+ const uriField = useRef()
+ const isError = useSelector((state) => state.demo.isError)
+ const errorMsg = useSelector((state) => state.demo.errorMsg)
+ const dispatch = useDispatch()
const handleClick = async (e) => {
- dispatch(showDemo(false));
- const URILink = uriField.current.value;
- e.preventDefault();
+ dispatch(showDemo(false))
+ const URILink = uriField.current.value
+ e.preventDefault()
- const fetchEndpoint = await checkEndpoint(URILink);
+ const fetchEndpoint = await checkEndpoint(URILink)
if (URILink.length > 0 && fetchEndpoint.length > 0) {
- const encryptedURL = CryptoJS.AES.encrypt(URILink, secretKey).toString(); //Encrypting user-inputted DB URI string
- fetchData(encryptedURL, fetchEndpoint);
+ const encryptedURL = CryptoJS.AES.encrypt(URILink, secretKey).toString() //Encrypting user-inputted DB URI string
+ fetchData(encryptedURL, fetchEndpoint)
} else {
- dispatch(setErrorMsg('Please enter a valid PostgreSQL or MongoDB URI'));
- dispatch(setIsError(true));
+ dispatch(setErrorMsg('Please enter a valid PostgreSQL or MongoDB URI'))
+ dispatch(setIsError(true))
}
- };
+ }
const checkEndpoint = async (URILink) => {
- const mongodbURI = 'convert-mongo-db';
- const sqlURI = 'convert-sql-db';
+ const mongodbURI = 'convert-mongo-db'
+ const sqlURI = 'convert-sql-db'
if (URILink.includes('postgres://')) {
- return sqlURI;
+ return sqlURI
} else if (URILink.includes('mongodb+srv://')) {
- return mongodbURI;
+ return mongodbURI
} else {
- return '';
+ return ''
}
- };
+ }
return (
<>
@@ -54,7 +61,7 @@ function DbInput({ fetchData }) {
initialValue=''
ref={uriField}
onKeyDown={(e) => {
- if (e.key === 'Enter') handleClick(e);
+ if (e.key === 'Enter') handleClick(e)
}}
/>
@@ -68,12 +75,11 @@ function DbInput({ fetchData }) {
size='sm'
css={{ px: '$14' }}
onClick={(e) => {
- dispatch(setQueries(''));
- dispatch(setIsError(false));
- dispatch(setErrorMsg(''));
- handleClick(e);
- }}
- >
+ dispatch(setQueries(''))
+ dispatch(setIsError(false))
+ dispatch(setErrorMsg(''))
+ handleClick(e)
+ }}>
Generate
@@ -89,22 +95,21 @@ function DbInput({ fetchData }) {
size='sm'
css={{ px: '$10' }}
onClick={() => {
- dispatch(setIsError(false));
- dispatch(showDemo(false)); //update showDemo state in redux
- dispatch(setQueries(''));
- dispatch(setShowLoader(true));
+ dispatch(setIsError(false))
+ dispatch(showDemo(false)) //update showDemo state in redux
+ dispatch(setQueries(''))
+ dispatch(setShowLoader(true))
setTimeout(() => {
- dispatch(setShowLoader(false));
- dispatch(showDemo(true)); //update showDemo state in redux
- dispatch(setShowDBInfo(true));
- }, 700);
- }}
- >
+ dispatch(setShowLoader(false))
+ dispatch(showDemo(true)) //update showDemo state in redux
+ dispatch(setShowDBInfo(true))
+ }, 700)
+ }}>
Sample Database
>
- );
+ )
}
-export default DbInput;
+export default DbInput
diff --git a/components/DbUri.js b/components/DbUri.js
index 0ec96ee..4883fd2 100644
--- a/components/DbUri.js
+++ b/components/DbUri.js
@@ -1,17 +1,17 @@
-import React from 'react';
-import { useSelector } from 'react-redux';
-import { motion, AnimatePresence } from 'framer-motion';
+import React from 'react'
+import { useSelector } from 'react-redux'
+import { motion, AnimatePresence } from 'framer-motion'
-import DbInput from '../components/DbInput';
-import DbInfo from '../components/DbInfo';
-import styles from '../styles/DbUri.module.css';
+import DbInput from '../components/DbInput'
+import DbInfo from '../components/DbInfo'
+import styles from '../styles/DbUri.module.css'
-const easing = [0.83, 0, 0.17, 1];
+const easing = [0.83, 0, 0.17, 1]
const fadeInRight = {
initial: {
x: [-400, 50, 0],
- opacity: 1,
+ opacity: 1
},
animate: {
x: 0,
@@ -20,25 +20,34 @@ const fadeInRight = {
delay: 10,
// type: 'spring',
duration: 1.0,
- ease: easing,
- },
+ ease: easing
+ }
},
exit: {
opacity: 1,
- x: [-400, 50, 0],
- },
-};
+ x: [-400, 50, 0]
+ }
+}
function DbUri({ hidePanel, fetchData, dbData, setDbData }) {
- const showDBInfo = useSelector((state) => state.demo.showDBInfo);
+ const showDBInfo = useSelector((state) => state.demo.showDBInfo)
return (
-
- {showDBInfo ? : }
+
+ {showDBInfo ? (
+
+ ) : (
+
+ )}
- );
+ )
}
-export default DbUri;
+export default DbUri
diff --git a/components/Features.js b/components/Features.js
index d4236f6..0425172 100644
--- a/components/Features.js
+++ b/components/Features.js
@@ -1,11 +1,11 @@
-import React from 'react';
-import Image from 'next/image';
+import React from 'react'
+import Image from 'next/image'
-import styles from '../styles/Learn.module.css';
-import DbInput from '../public/home1.gif';
-import GQLCode from '../public/home2.gif';
-import ExportCode from '../public/home3.gif';
-import Visualize from '../public/home4.gif';
+import styles from '../styles/Learn.module.css'
+import DbInput from '../public/home1.gif'
+import GQLCode from '../public/home2.gif'
+import ExportCode from '../public/home3.gif'
+import Visualize from '../public/home4.gif'
function Features({ index, title, description }) {
if (index === 0) {
@@ -20,7 +20,7 @@ function Features({ index, title, description }) {
- );
+ )
}
if (index === 1) {
return (
@@ -34,7 +34,7 @@ function Features({ index, title, description }) {
- );
+ )
}
if (index === 2) {
return (
@@ -48,7 +48,7 @@ function Features({ index, title, description }) {
- );
+ )
}
if (index === 3) {
return (
@@ -62,8 +62,8 @@ function Features({ index, title, description }) {
- );
+ )
}
}
-export default Features;
+export default Features
diff --git a/components/GQLevated.js b/components/GQLevated.js
index e1e2b21..ac39980 100644
--- a/components/GQLevated.js
+++ b/components/GQLevated.js
@@ -1,9 +1,9 @@
-import React from 'react';
-import Link from 'next/link';
-import Image from 'next/image';
+import React from 'react'
+import Link from 'next/link'
+import Image from 'next/image'
-import GQLevatedLogo from '../public/GQL_ASSET.svg';
-import styles from '../styles/Nav.module.css';
+import GQLevatedLogo from '../public/GQL_ASSET.svg'
+import styles from '../styles/Nav.module.css'
function GQLevated() {
return (
@@ -12,7 +12,7 @@ function GQLevated() {
- );
+ )
}
-export default GQLevated;
+export default GQLevated
diff --git a/components/GitHubStar.js b/components/GitHubStar.js
index a12a990..b45acfb 100644
--- a/components/GitHubStar.js
+++ b/components/GitHubStar.js
@@ -1,12 +1,12 @@
-import React from 'react';
-import Image from 'next/image';
+import React from 'react'
+import Image from 'next/image'
-import styles from '../styles/GitHubStar.module.css';
-import LinkedInLogo from '../public/Linkedin-logo-on-transparent-Background-PNG-.png';
-import GitHubLogo from '../public/GitHub-Mark-64px.png';
-import GitHubButton from 'react-github-btn';
-import GraphqlLogo from '../public/graphql2.png';
-import MediumLogo from '../public/medium-monogram-480.png';
+import styles from '../styles/GitHubStar.module.css'
+import LinkedInLogo from '../public/Linkedin-logo-on-transparent-Background-PNG-.png'
+import GitHubLogo from '../public/GitHub-Mark-64px.png'
+import GitHubButton from 'react-github-btn'
+import GraphqlLogo from '../public/graphql2.png'
+import MediumLogo from '../public/medium-monogram-480.png'
function GitHubStar() {
return (
@@ -20,20 +20,31 @@ function GitHubStar() {
+ rel='noreferrer noopener'>
-
+
-
+
-
+
@@ -43,14 +54,13 @@ function GitHubStar() {
data-icon='octicon-star'
data-size='large'
data-show-count='true'
- aria-label='Star oslabs-beta/GQLevated on GitHub'
- >
+ aria-label='Star oslabs-beta/GQLevated on GitHub'>
Star
- );
+ )
}
-export default GitHubStar;
+export default GitHubStar
diff --git a/components/Hero.js b/components/Hero.js
index eb913bd..e59aa5e 100644
--- a/components/Hero.js
+++ b/components/Hero.js
@@ -1,23 +1,23 @@
-import React from 'react';
-import Link from 'next/link';
-import Image from 'next/image';
-import { motion } from 'framer-motion';
-import { Spacer } from '@nextui-org/react';
+import React from 'react'
+import Link from 'next/link'
+import Image from 'next/image'
+import { motion } from 'framer-motion'
+import { Spacer } from '@nextui-org/react'
-import styles from '../styles/Hero.module.css';
-import GQLLogo from '../public/LOGO.svg';
+import styles from '../styles/Hero.module.css'
+import GQLLogo from '../public/LOGO.svg'
-const easing = [0.17, 0.67, 0.84, 0.66];
+const easing = [0.17, 0.67, 0.84, 0.66]
const rotate = {
initial: {
rotate: [0, 750, 720],
transition: {
linear: easing,
- duration: 2.2,
- },
- },
-};
+ duration: 2.2
+ }
+ }
+}
function Hero() {
return (
@@ -34,7 +34,7 @@ function Hero() {
Learn More
- );
+ )
}
-export default Hero;
+export default Hero
diff --git a/components/HiddenURIPanel.js b/components/HiddenURIPanel.js
index 5d35bc9..00d4611 100644
--- a/components/HiddenURIPanel.js
+++ b/components/HiddenURIPanel.js
@@ -1,14 +1,14 @@
-import React, { useRef, useState, useEffect } from 'react';
-import { motion } from 'framer-motion';
+import React, { useRef, useState, useEffect } from 'react'
+import { motion } from 'framer-motion'
-import styles from '../styles/HiddenURIPanel.module.css';
+import styles from '../styles/HiddenURIPanel.module.css'
-const easing = [0.83, 0, 0.17, 1];
+const easing = [0.83, 0, 0.17, 1]
const fadeInLeft = {
initial: {
x: [0, 10, 0],
- opacity: 1,
+ opacity: 1
},
animate: {
x: 0,
@@ -16,31 +16,31 @@ const fadeInLeft = {
transition: {
delay: 10,
type: 'bounce',
- duration: 1.0,
- },
- },
-};
+ duration: 1.0
+ }
+ }
+}
function HiddenURIPanel({ showPanel }) {
- const [showHoverPanel, setShowHoverPanel] = useState(false);
- const panelRef = useRef();
+ const [showHoverPanel, setShowHoverPanel] = useState(false)
+ const panelRef = useRef()
useEffect(() => {
if (showHoverPanel) {
- panelRef.current.style.boxShadow = '0 0 10px #cbcdd0';
- panelRef.current.style.backgroundColor = 'var(--secondary-color)';
- panelRef.current.style.opacity = '0.5';
+ panelRef.current.style.boxShadow = '0 0 10px #cbcdd0'
+ panelRef.current.style.backgroundColor = 'var(--secondary-color)'
+ panelRef.current.style.opacity = '0.5'
} else {
- panelRef.current.style.boxShadow = '';
- panelRef.current.style.backgroundColor = '';
+ panelRef.current.style.boxShadow = ''
+ panelRef.current.style.backgroundColor = ''
}
- }, [showHoverPanel]);
+ }, [showHoverPanel])
const bounceTransition = {
duration: 0.4,
yoyo: Infinity,
- ease: 'easeOut',
- };
+ ease: 'easeOut'
+ }
return (
showPanel()}
onMouseOver={() => setShowHoverPanel(true)}
- onMouseLeave={() => setShowHoverPanel(false)}
- >
- );
+ onMouseLeave={() => setShowHoverPanel(false)}>
+ )
}
-export default HiddenURIPanel;
+export default HiddenURIPanel
diff --git a/components/Layout.js b/components/Layout.js
index 1019a52..e3285d5 100644
--- a/components/Layout.js
+++ b/components/Layout.js
@@ -1,7 +1,7 @@
-import React from 'react';
+import React from 'react'
-import Nav from '../components/Nav';
-import styles from '../styles/Layout.module.css';
+import Nav from '../components/Nav'
+import styles from '../styles/Layout.module.css'
function Layout({ children }) {
return (
@@ -9,7 +9,7 @@ function Layout({ children }) {
{children}
>
- );
+ )
}
-export default Layout;
+export default Layout
diff --git a/components/LearnFeatures.js b/components/LearnFeatures.js
index 7b76b0e..5e9a19d 100644
--- a/components/LearnFeatures.js
+++ b/components/LearnFeatures.js
@@ -1,30 +1,30 @@
-import React from 'react';
-import { Spacer } from '@nextui-org/react';
+import React from 'react'
+import { Spacer } from '@nextui-org/react'
-import styles from '../styles/Learn.module.css';
-import Features from './Features';
+import styles from '../styles/Learn.module.css'
+import Features from './Features'
function LearnFeatures() {
const features = [
[
'Connect to your database',
- "Enter your PostgreSQL or MongoDB connection string and connect to your database. Don't have a connection string but still want to see how it works? No problem! Connect to our PostgresQL Sample Database and see GQLevated in action.",
+ "Enter your PostgreSQL or MongoDB connection string and connect to your database. Don't have a connection string but still want to see how it works? No problem! Connect to our PostgresQL Sample Database and see GQLevated in action."
],
[
'Generate your GraphQL Code',
- 'With one simple click of a button GQLevated connects to your database, parses the data and generates the corresponding GraphQL code for you. This production-ready GraphQL code includes server-side Types, Root Queries and Mutations as well as client-side Queries and Mutations. It is displayed for you in an easy to reason about way and ready to be injected into your own application.',
+ 'With one simple click of a button GQLevated connects to your database, parses the data and generates the corresponding GraphQL code for you. This production-ready GraphQL code includes server-side Types, Root Queries and Mutations as well as client-side Queries and Mutations. It is displayed for you in an easy to reason about way and ready to be injected into your own application.'
],
[
'Export your GraphQL Code',
- 'In addition to copying and pasting the newly generated GraphQL code straight from the browser display, users also have the option to export their customized GraphQL code as individual JavaScript files. Simply click on the ‘Export Code‘ button in the corresponding container of the code that you wish to download.',
+ 'In addition to copying and pasting the newly generated GraphQL code straight from the browser display, users also have the option to export their customized GraphQL code as individual JavaScript files. Simply click on the ‘Export Code‘ button in the corresponding container of the code that you wish to download.'
],
- ['Visualize your GraphQL Schema', 'Visualize and interact with your database relationships!'],
- ];
+ ['Visualize your GraphQL Schema', 'Visualize and interact with your database relationships!']
+ ]
- const introFeatures = [];
+ const introFeatures = []
for (let i = 0; i < features.length; i++) {
- const feature = features[i];
- introFeatures.push( );
+ const feature = features[i]
+ introFeatures.push( )
}
return (
@@ -36,17 +36,20 @@ function LearnFeatures() {
- Our Web Development Tool supplies users with customized, production-ready GraphQL code including server-side Types, Root Queries and Mutations as
- well as client-side Queries and Mutations. This allows developers to spend more time solving problems and less time tediously writing GraphQL code,
- thus ELEVATING the project as a whole.
+ Our Web Development Tool supplies users with customized, production-ready GraphQL code
+ including server-side Types, Root Queries and Mutations as well as client-side Queries
+ and Mutations. This allows developers to spend more time solving problems and less time
+ tediously writing GraphQL code, thus ELEVATING the project as a whole.
- And it’s free to use for everyone - no need to create an account!
+
+ And it’s free to use for everyone - no need to create an account!
+
{introFeatures}
- );
+ )
}
-export default LearnFeatures;
+export default LearnFeatures
diff --git a/components/Loader.js b/components/Loader.js
index 2b5cf77..5d16829 100644
--- a/components/Loader.js
+++ b/components/Loader.js
@@ -1,20 +1,20 @@
-import React, { useEffect } from 'react';
-import { motion } from 'framer-motion';
+import React, { useEffect } from 'react'
+import { motion } from 'framer-motion'
-import GQLLogo from '../public/LOGO.svg';
-import Image from 'next/image';
+import GQLLogo from '../public/LOGO.svg'
+import Image from 'next/image'
-const easing = [0.17, 0.67, 0.84, 0.66];
+const easing = [0.17, 0.67, 0.84, 0.66]
const rotate = {
initial: {
rotate: [0, 750, 720],
transition: {
linear: easing,
- duration: 0.7,
- },
- },
-};
+ duration: 0.7
+ }
+ }
+}
function Loader() {
return (
@@ -23,7 +23,7 @@ function Loader() {
- );
+ )
}
-export default Loader;
+export default Loader
diff --git a/components/Nav.js b/components/Nav.js
index 213c41f..82c9e95 100644
--- a/components/Nav.js
+++ b/components/Nav.js
@@ -1,9 +1,9 @@
-import Link from 'next/link';
-import React from 'react';
+import Link from 'next/link'
+import React from 'react'
-import styles from '../styles/Nav.module.css';
-import GitHubStar from './GitHubStar';
-import GQLevated from './GQLevated.js';
+import styles from '../styles/Nav.module.css'
+import GitHubStar from './GitHubStar'
+import GQLevated from './GQLevated.js'
function Nav() {
return (
@@ -29,7 +29,7 @@ function Nav() {
- );
+ )
}
-export default Nav;
+export default Nav
diff --git a/components/Team.js b/components/Team.js
index bf7bfc9..577b24b 100644
--- a/components/Team.js
+++ b/components/Team.js
@@ -1,14 +1,14 @@
-import React from 'react';
-import { Container, Row, Grid, Card, Text, Divider, Link, Spacer } from '@nextui-org/react';
-import Image from 'next/image';
+import React from 'react'
+import { Container, Row, Grid, Card, Text, Divider, Link, Spacer } from '@nextui-org/react'
+import Image from 'next/image'
-import styles from '../styles/Team.module.css';
-import JC from '../public/JC.png';
-import JA from '../public/JA.png';
-import NG from '../public/NG.png';
-import QC from '../public/QC.png';
-import GitHubLogo from '../public/GitHub-Mark-Light-64px.png';
-import LinkedInLogo from '../public/Linkedin-logo-on-transparent-Background-PNG-.png';
+import styles from '../styles/Team.module.css'
+import JC from '../public/JC.png'
+import JA from '../public/JA.png'
+import NG from '../public/NG.png'
+import QC from '../public/QC.png'
+import GitHubLogo from '../public/GitHub-Mark-Light-64px.png'
+import LinkedInLogo from '../public/Linkedin-logo-on-transparent-Background-PNG-.png'
function Team() {
const list = [
@@ -17,30 +17,30 @@ function Team() {
img: JA,
gitlink: 'https://github.com/JohnAlicastro',
linkedin: 'https://www.linkedin.com/in/johnalicastro',
- bios: 'John Alicastro is a full-stack JavaScript engineer specializing in React and Express with a focus in front-end performance optimization and server-side data transfer protocols. Additional concentrations in tech include testing, auth and SQL. His interest in the inner workings of GraphQL made GQLevated a perfect fit. Prior to GQLevated, John worked as a songwriter and producer in New York City, best known for his work with WWE Music Group.',
+ bios: 'John Alicastro is a full-stack JavaScript engineer specializing in React and Express with a focus in front-end performance optimization and server-side data transfer protocols. Additional concentrations in tech include testing, auth and SQL. His interest in the inner workings of GraphQL made GQLevated a perfect fit. Prior to GQLevated, John worked as a songwriter and producer in New York City, best known for his work with WWE Music Group.'
},
{
name: 'Johnson Che',
img: JC,
gitlink: 'https://github.com/JohnsonChe',
linkedin: 'https://www.linkedin.com/in/JohnsonChe/',
- bios: 'Johnson Che is a full-stack software engineer with experience in React, Node.js, Express, with a passion for frontend development. When he isn\t coding, he enjoys hiking, indoor bouldering, and keeping up with the latest tech.',
+ bios: 'Johnson Che is a full-stack software engineer with experience in React, Node.js, Express, with a passion for frontend development. When he isn\t coding, he enjoys hiking, indoor bouldering, and keeping up with the latest tech.'
},
{
name: 'Nicholas Gonzalez',
img: NG,
gitlink: 'https://github.com/Nikootz',
linkedin: 'https://www.linkedin.com/in/nicholas-gonzalez-036b1751/',
- bios: 'Nicholas Gonzalez is a full-stack software engineer from Queens, NY with experience in React, Node.js, and Express, with a passion for problem solving and recursive algorithms. His love for creating and cultivating collaborative work environments made him a perfect fit for GQLevated. When not coding, Nick enjoys making and appreciating music or pushing his personal limits through focused learning and physical fitness.',
+ bios: 'Nicholas Gonzalez is a full-stack software engineer from Queens, NY with experience in React, Node.js, and Express, with a passion for problem solving and recursive algorithms. His love for creating and cultivating collaborative work environments made him a perfect fit for GQLevated. When not coding, Nick enjoys making and appreciating music or pushing his personal limits through focused learning and physical fitness.'
},
{
name: 'Quyen Calixto',
img: QC,
gitlink: 'https://github.com/QtieCoder',
linkedin: 'https://www.linkedin.com/in/quyencalixto',
- bios: 'Quyen is a full-stack software engineer from Brooklyn, NY, with experience in React and Express. She is passionate about solving complex problems and working in teams as well as learning new technologies. In her previous life, Quyen was an Internal Auditor with a passion for IT. In her spare time, when she’s not catching up on HK dramas, she enjoys dining at Michelin restaurants and chasing the latest foodie trends. ',
- },
- ];
+ bios: 'Quyen is a full-stack software engineer from Brooklyn, NY, with experience in React and Express. She is passionate about solving complex problems and working in teams as well as learning new technologies. In her previous life, Quyen was an Internal Auditor with a passion for IT. In her spare time, when she’s not catching up on HK dramas, she enjoys dining at Michelin restaurants and chasing the latest foodie trends. '
+ }
+ ]
return (
- );
+ )
}
-export default Team;
+export default Team
diff --git a/components/flowModal.js b/components/flowModal.js
index 7477f95..f374f10 100644
--- a/components/flowModal.js
+++ b/components/flowModal.js
@@ -1,42 +1,49 @@
-import React from 'react';
-import ReactFlow, { Background, Controls, Handle, Position } from 'react-flow-renderer';
-import { useDispatch, useSelector } from 'react-redux';
+import React from 'react'
+import ReactFlow, { Background, Controls, Handle, Position } from 'react-flow-renderer'
+import { useDispatch, useSelector } from 'react-redux'
-import { setShowFlowModal } from '../features/demoSlice';
-import { SQLSchema } from '../server/sampleDB';
+import { setShowFlowModal } from '../features/demoSlice'
+import { SQLSchema } from '../server/sampleDB'
function flowModal({ data }) {
- const dispatch = useDispatch();
- const showDemo = useSelector((state) => state.demo.showDemo);
- let flowData = data;
+ const dispatch = useDispatch()
+ const showDemo = useSelector((state) => state.demo.showDemo)
+ let flowData = data
- if (showDemo) flowData = SQLSchema;
+ if (showDemo) flowData = SQLSchema
- const elements = [];
- const tables = flowData.tables;
+ const elements = []
+ const tables = flowData.tables
- let positionX = 100;
- let positionY = 100;
- let row = 0;
+ let positionX = 100
+ let positionY = 100
+ let row = 0
//Iterate through all tables and
for (const table in tables) {
- let index = 0;
- const tableName = table;
- const tableFields = tables[table].columns;
- const tableReference = tables[table].referencedBy;
+ let index = 0
+ const tableName = table
+ const tableFields = tables[table].columns
+ const tableReference = tables[table].referencedBy
- const fields = [];
+ const fields = []
//Iterate through all of the fields within Table
for (const field in tableFields) {
- const dataType = tableFields[field].dataType;
+ const dataType = tableFields[field].dataType
fields.push(
-
+
{field}
{dataType}
- );
+ )
}
if (tableReference) {
@@ -47,10 +54,10 @@ function flowModal({ data }) {
target: ref,
animated: true,
label: ref,
- labelStyle: { fontSize: '1.6rem', fontWeight: 600 },
- };
+ labelStyle: { fontSize: '1.6rem', fontWeight: 600 }
+ }
- elements.push(edge);
+ elements.push(edge)
}
}
@@ -65,19 +72,19 @@ function flowModal({ data }) {
{fields}
- ),
+ )
},
- position: { x: positionX, y: positionY },
- };
+ position: { x: positionX, y: positionY }
+ }
- row += 1;
- positionY += 600;
+ row += 1
+ positionY += 600
if (row % 2 === 0) {
- positionY = 100;
- positionX += 550;
+ positionY = 100
+ positionX += 550
}
- elements.push(newNode);
+ elements.push(newNode)
}
return (
@@ -89,7 +96,7 @@ function flowModal({ data }) {
- );
+ )
}
const CustomNodeComponent = ({ data }) => {
@@ -97,15 +104,25 @@ const CustomNodeComponent = ({ data }) => {
- );
-};
+ )
+}
const nodeTypes = {
- special: CustomNodeComponent,
-};
+ special: CustomNodeComponent
+}
const customNodeStyle = {
color: '#403D39',
@@ -117,8 +134,8 @@ const customNodeStyle = {
borderColor: '#8cbbad',
transition: 'all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
boxShadow: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)',
- width: 'min-content',
-};
+ width: 'min-content'
+}
const titleStyle = {
background: '#282b2e',
@@ -128,11 +145,11 @@ const titleStyle = {
padding: '5px 20px',
borderTopLeftRadius: '5px',
borderTopRightRadius: '5px',
- fontFamily: 'Montserrat, sans-serif',
-};
+ fontFamily: 'Montserrat, sans-serif'
+}
const containerStyle = {
- padding: 10,
-};
+ padding: 10
+}
-export default flowModal;
+export default flowModal
diff --git a/features/demoSlice.js b/features/demoSlice.js
index 424fda9..dd9251f 100644
--- a/features/demoSlice.js
+++ b/features/demoSlice.js
@@ -1,4 +1,4 @@
-import { createSlice } from '@reduxjs/toolkit';
+import { createSlice } from '@reduxjs/toolkit'
const initialStateValue = {
queries: undefined,
@@ -7,8 +7,8 @@ const initialStateValue = {
errorMsg: '',
showLoader: false,
showFlowModal: false,
- showDBInfo: false,
-};
+ showDBInfo: false
+}
//REDUCERS
export const demoSlice = createSlice({
@@ -16,29 +16,38 @@ export const demoSlice = createSlice({
initialState: initialStateValue,
reducers: {
setQueries: (state, action) => {
- state.queries = action.payload;
+ state.queries = action.payload
},
showDemo: (state, action) => {
- state.showDemo = action.payload;
+ state.showDemo = action.payload
},
setIsError: (state, action) => {
- state.isError = action.payload;
+ state.isError = action.payload
},
setErrorMsg: (state, action) => {
- state.errorMsg = action.payload;
+ state.errorMsg = action.payload
},
setShowLoader: (state, action) => {
- state.showLoader = action.payload;
+ state.showLoader = action.payload
},
setShowFlowModal: (state, action) => {
- state.showFlowModal = action.payload;
+ state.showFlowModal = action.payload
},
setShowDBInfo: (state, action) => {
- state.showDBInfo = action.payload;
- },
- },
-});
+ state.showDBInfo = action.payload
+ }
+ }
+})
-export const { setQueries, showDemo, setIsError, setErrorMsg, setShowLoader, setShowFlowModal, setFlowElements, setShowDBInfo } = demoSlice.actions;
+export const {
+ setQueries,
+ showDemo,
+ setIsError,
+ setErrorMsg,
+ setShowLoader,
+ setShowFlowModal,
+ setFlowElements,
+ setShowDBInfo
+} = demoSlice.actions
-export default demoSlice.reducer;
+export default demoSlice.reducer
diff --git a/package-lock.json b/package-lock.json
index 98f6856..9817a46 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -366,10 +366,19 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@babel/helper-string-parser": {
+ "version": "7.24.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz",
+ "integrity": "sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==",
+ "dev": true,
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@babel/helper-validator-identifier": {
- "version": "7.16.7",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz",
- "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==",
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
+ "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
"engines": {
"node": ">=6.9.0"
}
@@ -485,9 +494,9 @@
}
},
"node_modules/@babel/parser": {
- "version": "7.16.12",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.12.tgz",
- "integrity": "sha512-VfaV15po8RiZssrkPweyvbGVSe4x2y+aciFCgn0n0/SJMR22cwofRV1mtnJQYcSB1wUTaA/X1LnA3es66MCO5A==",
+ "version": "7.24.1",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz",
+ "integrity": "sha512-Zo9c7N3xdOIQrNip7Lc9wvRPzlRtovHVE4lkz8WEDr7uYh/GMQhSiIgFxGIArRHYdJE5kxtZjAf8rT0xhdLCzg==",
"bin": {
"parser": "bin/babel-parser.js"
},
@@ -1560,6 +1569,84 @@
"node": ">=6"
}
},
+ "node_modules/@tootallnate/once": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
+ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==",
+ "dev": true,
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/@types/babel__core": {
+ "version": "7.20.5",
+ "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
+ "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==",
+ "dev": true,
+ "dependencies": {
+ "@babel/parser": "^7.20.7",
+ "@babel/types": "^7.20.7",
+ "@types/babel__generator": "*",
+ "@types/babel__template": "*",
+ "@types/babel__traverse": "*"
+ }
+ },
+ "node_modules/@types/babel__core/node_modules/@babel/types": {
+ "version": "7.24.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz",
+ "integrity": "sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==",
+ "dev": true,
+ "dependencies": {
+ "@babel/helper-string-parser": "^7.23.4",
+ "@babel/helper-validator-identifier": "^7.22.20",
+ "to-fast-properties": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@types/babel__generator": {
+ "version": "7.6.8",
+ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz",
+ "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==",
+ "dev": true,
+ "dependencies": {
+ "@babel/types": "^7.0.0"
+ }
+ },
+ "node_modules/@types/babel__template": {
+ "version": "7.4.4",
+ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz",
+ "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==",
+ "dev": true,
+ "dependencies": {
+ "@babel/parser": "^7.1.0",
+ "@babel/types": "^7.0.0"
+ }
+ },
+ "node_modules/@types/babel__traverse": {
+ "version": "7.20.5",
+ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.5.tgz",
+ "integrity": "sha512-WXCyOcRtH37HAUkpXhUduaxdm82b4GSlyTqajXviN4EfiuPgNYR109xMCKvpl6zPIpua0DGlMEDCq+g8EdoheQ==",
+ "dev": true,
+ "dependencies": {
+ "@babel/types": "^7.20.7"
+ }
+ },
+ "node_modules/@types/babel__traverse/node_modules/@babel/types": {
+ "version": "7.24.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz",
+ "integrity": "sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==",
+ "dev": true,
+ "dependencies": {
+ "@babel/helper-string-parser": "^7.23.4",
+ "@babel/helper-validator-identifier": "^7.22.20",
+ "to-fast-properties": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
"node_modules/@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@@ -1598,6 +1685,15 @@
"@types/range-parser": "*"
}
},
+ "node_modules/@types/graceful-fs": {
+ "version": "4.1.9",
+ "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",
+ "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==",
+ "dev": true,
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/hast": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
@@ -1711,6 +1807,12 @@
"@types/node": "*"
}
},
+ "node_modules/@types/stack-utils": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz",
+ "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==",
+ "dev": true
+ },
"node_modules/@types/unist": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
@@ -9718,10 +9820,16 @@
}
}
},
+ "@babel/helper-string-parser": {
+ "version": "7.24.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz",
+ "integrity": "sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==",
+ "dev": true
+ },
"@babel/helper-validator-identifier": {
- "version": "7.16.7",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz",
- "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw=="
+ "version": "7.22.20",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
+ "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A=="
},
"@babel/helper-validator-option": {
"version": "7.16.7",
@@ -9811,9 +9919,9 @@
}
},
"@babel/parser": {
- "version": "7.16.12",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.12.tgz",
- "integrity": "sha512-VfaV15po8RiZssrkPweyvbGVSe4x2y+aciFCgn0n0/SJMR22cwofRV1mtnJQYcSB1wUTaA/X1LnA3es66MCO5A=="
+ "version": "7.24.1",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.1.tgz",
+ "integrity": "sha512-Zo9c7N3xdOIQrNip7Lc9wvRPzlRtovHVE4lkz8WEDr7uYh/GMQhSiIgFxGIArRHYdJE5kxtZjAf8rT0xhdLCzg=="
},
"@babel/plugin-syntax-async-generators": {
"version": "7.8.4",
@@ -10575,6 +10683,79 @@
"defer-to-connect": "^1.0.1"
}
},
+ "@tootallnate/once": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
+ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==",
+ "dev": true
+ },
+ "@types/babel__core": {
+ "version": "7.20.5",
+ "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
+ "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==",
+ "dev": true,
+ "requires": {
+ "@babel/parser": "^7.20.7",
+ "@babel/types": "^7.20.7",
+ "@types/babel__generator": "*",
+ "@types/babel__template": "*",
+ "@types/babel__traverse": "*"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.24.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz",
+ "integrity": "sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-string-parser": "^7.23.4",
+ "@babel/helper-validator-identifier": "^7.22.20",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
+ }
+ },
+ "@types/babel__generator": {
+ "version": "7.6.8",
+ "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz",
+ "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.0.0"
+ }
+ },
+ "@types/babel__template": {
+ "version": "7.4.4",
+ "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz",
+ "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==",
+ "dev": true,
+ "requires": {
+ "@babel/parser": "^7.1.0",
+ "@babel/types": "^7.0.0"
+ }
+ },
+ "@types/babel__traverse": {
+ "version": "7.20.5",
+ "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.5.tgz",
+ "integrity": "sha512-WXCyOcRtH37HAUkpXhUduaxdm82b4GSlyTqajXviN4EfiuPgNYR109xMCKvpl6zPIpua0DGlMEDCq+g8EdoheQ==",
+ "dev": true,
+ "requires": {
+ "@babel/types": "^7.20.7"
+ },
+ "dependencies": {
+ "@babel/types": {
+ "version": "7.24.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz",
+ "integrity": "sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-string-parser": "^7.23.4",
+ "@babel/helper-validator-identifier": "^7.22.20",
+ "to-fast-properties": "^2.0.0"
+ }
+ }
+ }
+ },
"@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@@ -10613,6 +10794,15 @@
"@types/range-parser": "*"
}
},
+ "@types/graceful-fs": {
+ "version": "4.1.9",
+ "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",
+ "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==",
+ "dev": true,
+ "requires": {
+ "@types/node": "*"
+ }
+ },
"@types/hast": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
@@ -10726,6 +10916,12 @@
"@types/node": "*"
}
},
+ "@types/stack-utils": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz",
+ "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==",
+ "dev": true
+ },
"@types/unist": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
diff --git a/pages/_app.js b/pages/_app.js
index 3a5a53b..a3f69f2 100644
--- a/pages/_app.js
+++ b/pages/_app.js
@@ -1,9 +1,9 @@
-import { createTheme, NextUIProvider } from '@nextui-org/react';
-import { Provider } from 'react-redux';
+import { createTheme, NextUIProvider } from '@nextui-org/react'
+import { Provider } from 'react-redux'
-import Layout from '../components/Layout';
-import { store } from '../store';
-import '../styles/globals.css';
+import Layout from '../components/Layout'
+import { store } from '../store'
+import '../styles/globals.css'
const theme = createTheme({
type: 'dark',
@@ -15,12 +15,12 @@ const theme = createTheme({
selection: '#005cce',
codeLight: 'rgba(27,31,36,0)',
gradient: 'linear-gradient(to right, #a359d8, rgba(21, 5, 194, 0.845)',
- myDarkColor: '#fffff',
+ myDarkColor: '#fffff'
},
space: {},
- fonts: {},
- },
-});
+ fonts: {}
+ }
+})
function MyApp({ Component, pageProps }) {
return (
@@ -31,7 +31,7 @@ function MyApp({ Component, pageProps }) {
- );
+ )
}
-export default MyApp;
+export default MyApp
diff --git a/pages/about.js b/pages/about.js
index 4a0b3db..e50ff3d 100644
--- a/pages/about.js
+++ b/pages/about.js
@@ -1,9 +1,8 @@
-import Head from 'next/head';
-import React from 'react';
+import Head from 'next/head'
+import React from 'react'
import PreviewImage from '../public/GQLevatedWordMark.png'
-
-import Team from '../components/Team';
+import Team from '../components/Team'
function About() {
return (
@@ -15,7 +14,7 @@ function About() {
- );
+ )
}
-export default About;
+export default About
diff --git a/pages/demo.js b/pages/demo.js
index 790b5d6..dce5711 100644
--- a/pages/demo.js
+++ b/pages/demo.js
@@ -1,84 +1,90 @@
-import React, { useState, useEffect } from 'react';
-import { useSelector, useDispatch } from 'react-redux';
-import Head from 'next/head';
+import React, { useState, useEffect } from 'react'
+import { useSelector, useDispatch } from 'react-redux'
+import Head from 'next/head'
import PreviewImage from '../public/GQLevatedWordMark.png'
-
-import { setQueries, showDemo, setIsError, setErrorMsg, setShowLoader, setShowDBInfo } from '../features/demoSlice';
-import DbUri from '../components/DbUri';
-import Loader from '../components/Loader';
-import FlowModal from '../components/flowModal';
-import CodeBoxContainer from '../components/CodeBoxContainer';
-import HiddenURIPanel from '../components/HiddenURIPanel';
-import styles from '../styles/Demo.module.css';
+import {
+ setQueries,
+ showDemo,
+ setIsError,
+ setErrorMsg,
+ setShowLoader,
+ setShowDBInfo
+} from '../features/demoSlice'
+import DbUri from '../components/DbUri'
+import Loader from '../components/Loader'
+import FlowModal from '../components/flowModal'
+import CodeBoxContainer from '../components/CodeBoxContainer'
+import HiddenURIPanel from '../components/HiddenURIPanel'
+import styles from '../styles/Demo.module.css'
function Demo() {
- const [showURIPanel, setShowURIPanel] = useState(true);
- const [flowModalData, setFlowModalData] = useState();
- const [dbData, setDbData] = useState();
+ const [showURIPanel, setShowURIPanel] = useState(true)
+ const [flowModalData, setFlowModalData] = useState()
+ const [dbData, setDbData] = useState()
- const showLoader = useSelector((state) => state.demo.showLoader);
- const showFlowModal = useSelector((state) => state.demo.showFlowModal);
- const dispatch = useDispatch();
+ const showLoader = useSelector((state) => state.demo.showLoader)
+ const showFlowModal = useSelector((state) => state.demo.showFlowModal)
+ const dispatch = useDispatch()
//On Demo load, clear queries and demo flag
useEffect(() => {
return () => {
- dispatch(setQueries(''));
- dispatch(showDemo(false));
- dispatch(setIsError(false));
- dispatch(setShowDBInfo(false));
- };
- }, []);
+ dispatch(setQueries(''))
+ dispatch(showDemo(false))
+ dispatch(setIsError(false))
+ dispatch(setShowDBInfo(false))
+ }
+ }, [])
const fetchData = (uri, endpoint) => {
- dispatch(setShowLoader(true));
+ dispatch(setShowLoader(true))
fetch(`https://serene-cove-74017.herokuapp.com/${endpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ link: uri }),
+ body: JSON.stringify({ link: uri })
})
.then((res) => res.json())
.then(async (data) => {
if (data.err) {
setTimeout(() => {
- dispatch(setShowLoader(false));
- dispatch(setIsError(true));
- dispatch(setErrorMsg(data.err));
- }, 550);
+ dispatch(setShowLoader(false))
+ dispatch(setIsError(true))
+ dispatch(setErrorMsg(data.err))
+ }, 550)
} else {
// Successful Fetch Request
- setFlowModalData(null);
+ setFlowModalData(null)
if (endpoint === 'convert-mongo-db') {
setDbData({
name: data.DBName,
type: 'MongoDB',
- data: data.MongoSchema,
- });
- setFlowModalData(data.MongoSchema);
+ data: data.MongoSchema
+ })
+ setFlowModalData(data.MongoSchema)
} else if (endpoint === 'convert-sql-db') {
setDbData({
name: data.DBName,
type: 'PostgreSQL',
- data: data.SQLSchema,
- });
- setFlowModalData(data.SQLSchema);
+ data: data.SQLSchema
+ })
+ setFlowModalData(data.SQLSchema)
}
setTimeout(() => {
- dispatch(setShowLoader(false));
- dispatch(setShowDBInfo(true));
- dispatch(setQueries(data));
- }, 550);
+ dispatch(setShowLoader(false))
+ dispatch(setShowDBInfo(true))
+ dispatch(setQueries(data))
+ }, 550)
}
})
.catch(async (err) => {
- dispatch(setShowLoader(false));
- dispatch(setErrorMsg(err));
- dispatch(setIsError(true));
- });
- };
+ dispatch(setShowLoader(false))
+ dispatch(setErrorMsg(err))
+ dispatch(setIsError(true))
+ })
+ }
return (
@@ -87,17 +93,23 @@ function Demo() {
+ // Create a component
{showURIPanel ? (
- setShowURIPanel(false)} />
+ setShowURIPanel(false)}
+ />
) : (
setShowURIPanel(true)} />
)}
-
{showLoader && }
{showFlowModal && }
- );
+ )
}
-export default Demo;
+export default Demo
diff --git a/pages/index.js b/pages/index.js
index 8be6b15..fa44d44 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -1,8 +1,8 @@
-import Head from 'next/head';
+import Head from 'next/head'
import PreviewImage from '../public/GQLevatedWordMark.png'
-import styles from '../styles/HomeContent.module.css';
-import Hero from '../components/Hero';
-import LearnFeatures from '../components/LearnFeatures';
+import styles from '../styles/HomeContent.module.css'
+import Hero from '../components/Hero'
+import LearnFeatures from '../components/LearnFeatures'
export default function Home() {
return (
@@ -17,5 +17,5 @@ export default function Home() {
>
- );
+ )
}
diff --git a/server/TEMPREF.js b/server/TEMPREF.js
index 8b272ec..26a8aa6 100644
--- a/server/TEMPREF.js
+++ b/server/TEMPREF.js
@@ -22,12 +22,12 @@ databases = {
relation: {
tableIndex: -1,
fieldIndex: -1,
- refType: '',
+ refType: ''
},
refByIndex: 0,
refBy: {},
tableNum: 0,
- fieldNum: 0,
+ fieldNum: 0
},
1: {
name: 'Name',
@@ -42,11 +42,11 @@ databases = {
relation: {
tableIndex: -1,
fieldIndex: -1,
- refType: '',
+ refType: ''
},
refBy: {},
tableNum: 0,
- fieldNum: 1,
+ fieldNum: 1
},
2: {
name: 'Age',
@@ -61,22 +61,22 @@ databases = {
relation: {
tableIndex: -1,
fieldIndex: -1,
- refType: '',
+ refType: ''
},
refBy: {},
tableNum: 0,
- fieldNum: 2,
- },
+ fieldNum: 2
+ }
},
fieldsIndex: 3,
- tableID: 0,
- },
+ tableID: 0
+ }
},
selectedTable: {
type: '',
fields: {},
fieldsIndex: 1,
- tableID: -1,
+ tableID: -1
},
selectedField: {
name: '',
@@ -91,13 +91,11 @@ databases = {
relation: {
tableIndex: -1,
fieldIndex: -1,
- refType: '',
+ refType: ''
},
refBy: {},
tableNum: 0,
- fieldNum: -1,
- },
- },
-};
-
-
+ fieldNum: -1
+ }
+ }
+}
diff --git a/server/controllers/CryptoJSController.js b/server/controllers/CryptoJSController.js
index de6ae68..00e88cd 100644
--- a/server/controllers/CryptoJSController.js
+++ b/server/controllers/CryptoJSController.js
@@ -1,35 +1,38 @@
-const CryptoJS = require('crypto-js');
-const secretKey = require('../secretKey');
+const CryptoJS = require('crypto-js')
+const secretKey = require('../secretKey')
/* DEMO POSTGRESQL DB URI */
-const DEMO_PG_URI = 'postgres://zopukfce:9HtnUz7qn0mkyXDet_HCqe9-qXjbAZx1@ruby.db.elephantsql.com/zopukfce';
+const DEMO_PG_URI =
+ 'postgres://zopukfce:9HtnUz7qn0mkyXDet_HCqe9-qXjbAZx1@ruby.db.elephantsql.com/zopukfce'
/* FUNC TO DECRYPT USER PG URI SENT FROM FRONT-END */
const userURIDecrypted = (encryptedUserURI) => {
- const data = CryptoJS.AES.decrypt(encryptedUserURI, secretKey);
- const decryptedURI = data.toString(CryptoJS.enc.Utf8);
- return decryptedURI;
-};
+ const data = CryptoJS.AES.decrypt(encryptedUserURI, secretKey)
+ const decryptedURI = data.toString(CryptoJS.enc.Utf8)
+ return decryptedURI
+}
-const Controller = {};
+const Controller = {}
/* DECRYPT INCOMING USER URI MIDDLEWARE */
Controller.decryptURI = (req, res, next) => {
try {
/* If encypted user URI is in req.body.link
call userURIDecrypted to decrypt it and store in res.locals, otherwise use demo URI */
- req.body.link ? (res.locals.userURIDecrypted = userURIDecrypted(req.body.link)) : (res.locals.userURIDecrypted = DEMO_PG_URI);
- return next();
+ req.body.link
+ ? (res.locals.userURIDecrypted = userURIDecrypted(req.body.link))
+ : (res.locals.userURIDecrypted = DEMO_PG_URI)
+ return next()
} catch (error) {
const errObj = {
log: `Error caught in server middleware @ decryptURI: ${error}`,
status: 400,
message: {
- err: 'Unable to decrypt user Connection String',
- },
- };
- return next(errObj);
+ err: 'Unable to decrypt user Connection String'
+ }
+ }
+ return next(errObj)
}
-};
+}
-module.exports = Controller;
+module.exports = Controller
diff --git a/server/controllers/GQLClientController.js b/server/controllers/GQLClientController.js
index 82930d5..547e0e5 100644
--- a/server/controllers/GQLClientController.js
+++ b/server/controllers/GQLClientController.js
@@ -1,20 +1,20 @@
/* FUNCTION TO COMBINE ALL TABLES FROM EACH DB */
const createCombinedTables = (databases) => {
- let num = 0;
- const tablesCombined = {};
+ let num = 0
+ const tablesCombined = {}
for (const databaseIndex in databases) {
- const database = databases[databaseIndex];
+ const database = databases[databaseIndex]
for (const index in database.tables) {
- tablesCombined[num] = database.tables[index];
- num++;
+ tablesCombined[num] = database.tables[index]
+ num++
}
}
- return tablesCombined;
-};
+ return tablesCombined
+}
-const tab = ` `;
+const tab = ` `
-const Controller = {};
+const Controller = {}
/* ****************** BUILD CLIENT QUERIES BELOW ****************** */
@@ -22,74 +22,76 @@ const Controller = {};
Controller.convertToGQLClientQueriesCode = (req, res, next) => {
try {
// GET ALL TABLES FROM res.locals.preppedForGQL
- const tables = createCombinedTables(res.locals.preppedForGQL);
+ const tables = createCombinedTables(res.locals.preppedForGQL)
- let query = "import { gql } from 'apollo-boost';\n\n";
- const exportNames = [];
+ let query = "import { gql } from 'apollo-boost';\n\n"
+ const exportNames = []
for (const tableId in tables) {
- query += buildClientQueryAll(tables[tableId]);
- exportNames.push(`queryEvery${tables[tableId].type}`);
+ query += buildClientQueryAll(tables[tableId])
+ exportNames.push(`queryEvery${tables[tableId].type}`)
if (!!tables[tableId].fields[0]) {
- query += buildClientQueryById(tables[tableId]);
- exportNames.push(`query${tables[tableId].type}ById `);
+ query += buildClientQueryById(tables[tableId])
+ exportNames.push(`query${tables[tableId].type}ById `)
}
}
- let endString = 'export {';
+ let endString = 'export {'
exportNames.forEach((name, i) => {
if (i) {
- endString += `, ${name}`;
+ endString += `, ${name}`
} else {
- endString += ` ${name}`;
+ endString += ` ${name}`
}
- });
+ })
// return (query += `${endString}};`);
- res.locals.GQLClientQueriesCode = query += `${endString}};`;
- return next();
+ res.locals.GQLClientQueriesCode = query += `${endString}};`
+ return next()
} catch (error) {
const errObj = {
log: `Error in server middleware @ convertToGQLClientQueriesCode: ${error}`,
status: 400,
message: {
- err: 'Unable to parse Graphql Client Queries Code',
- },
- };
- return next(errObj);
+ err: 'Unable to parse Graphql Client Queries Code'
+ }
+ }
+ return next(errObj)
}
-};
+}
/* HELPER FUNC FOR Controller.convertToGQLClientQueriesCode */
function buildClientQueryAll(table) {
- let string = `const queryEvery${table.type} = gql\`\n`;
- string += `${tab}{\n`;
- string += `${tab}${tab}every${toTitleCase(table.type)} {\n`;
+ let string = `const queryEvery${table.type} = gql\`\n`
+ string += `${tab}{\n`
+ string += `${tab}${tab}every${toTitleCase(table.type)} {\n`
for (const fieldId in table.fields) {
- string += `${tab}${tab}${tab}${table.fields[fieldId].name}\n`;
+ string += `${tab}${tab}${tab}${table.fields[fieldId].name}\n`
}
- return (string += `${tab}${tab}}\n${tab}}\n\`\n\n`);
+ return (string += `${tab}${tab}}\n${tab}}\n\`\n\n`)
}
/* HELPER FUNC FOR Controller.convertToGQLClientQueriesCode */
function toTitleCase(refTypeName) {
- let name = refTypeName[0].toUpperCase();
- name += refTypeName.slice(1).toLowerCase();
- return name;
+ let name = refTypeName[0].toUpperCase()
+ name += refTypeName.slice(1).toLowerCase()
+ return name
}
/* HELPER FUNC FOR Controller.convertToGQLClientQueriesCode */
function buildClientQueryById(table) {
- let string = `const query${table.type}ById = gql\`\n`;
- string += `${tab}query($${table.fields[0].name}: ${table.fields[0].type}!) {\n`;
- string += `${tab}${tab}${table.type.toLowerCase()}(${table.fields[0].name}: $${table.fields[0].name}) {\n`;
+ let string = `const query${table.type}ById = gql\`\n`
+ string += `${tab}query($${table.fields[0].name}: ${table.fields[0].type}!) {\n`
+ string += `${tab}${tab}${table.type.toLowerCase()}(${table.fields[0].name}: $${
+ table.fields[0].name
+ }) {\n`
for (const fieldId in table.fields) {
- string += `${tab}${tab}${tab}${table.fields[fieldId].name}\n`;
+ string += `${tab}${tab}${tab}${table.fields[fieldId].name}\n`
}
- return (string += `${tab}${tab}}\n${tab}}\n\`\n\n`);
+ return (string += `${tab}${tab}}\n${tab}}\n\`\n\n`)
}
/* ****************** BUILD CLIENT MUTATIONS BELOW ****************** */
@@ -98,149 +100,155 @@ function buildClientQueryById(table) {
Controller.convertToGQLClientMutationsCode = (req, res, next) => {
try {
// GET ALL TABLES FROM res.locals.preppedForGQL
- const tables = createCombinedTables(res.locals.preppedForGQL);
+ const tables = createCombinedTables(res.locals.preppedForGQL)
- let query = "import { gql } from 'apollo-boost';\n\n";
- const exportNames = [];
+ let query = "import { gql } from 'apollo-boost';\n\n"
+ const exportNames = []
// Build mutations
for (const tableId in tables) {
// Build add mutations
- query += buildMutationParams(tables[tableId], 'add');
- query += buildTypeParams(tables[tableId], 'add');
- query += buildReturnValues(tables[tableId]);
- exportNames.push(`add${tables[tableId].type}Mutation`);
+ query += buildMutationParams(tables[tableId], 'add')
+ query += buildTypeParams(tables[tableId], 'add')
+ query += buildReturnValues(tables[tableId])
+ exportNames.push(`add${tables[tableId].type}Mutation`)
// Build delete and update mutations if there is an unique id
if (tables[tableId].fields[0]) {
// update mutations
- query += buildMutationParams(tables[tableId], 'update');
- query += buildTypeParams(tables[tableId], 'update');
- query += buildReturnValues(tables[tableId]);
- exportNames.push(`update${tables[tableId].type}Mutation`);
+ query += buildMutationParams(tables[tableId], 'update')
+ query += buildTypeParams(tables[tableId], 'update')
+ query += buildReturnValues(tables[tableId])
+ exportNames.push(`update${tables[tableId].type}Mutation`)
// delete mutations
- query += buildDeleteMutationParams(tables[tableId]);
- query += buildReturnValues(tables[tableId]);
- exportNames.push(`delete${tables[tableId].type}Mutation`);
+ query += buildDeleteMutationParams(tables[tableId])
+ query += buildReturnValues(tables[tableId])
+ exportNames.push(`delete${tables[tableId].type}Mutation`)
}
}
- let endString = `export {\n`;
+ let endString = `export {\n`
exportNames.forEach((name, i) => {
if (i === 0) {
- endString += `${tab}${name},\n`;
+ endString += `${tab}${name},\n`
} else {
- endString += `${tab}${name},\n`;
+ endString += `${tab}${name},\n`
}
- });
+ })
// return (query += `${endString}};`);
- res.locals.GQLClientMutationsCode = query += `${endString}};`;
- return next();
+ res.locals.GQLClientMutationsCode = query += `${endString}};`
+ return next()
} catch (error) {
const errObj = {
log: `Error in server middleware @ convertToGQLClientMutationsCode: ${error}`,
status: 400,
message: {
- err: 'Unable to parse Graphql Client Mutations Code',
- },
- };
- return next(errObj);
+ err: 'Unable to parse Graphql Client Mutations Code'
+ }
+ }
+ return next(errObj)
}
-};
+}
/* HELPER FUNC FOR Controller.convertToGQLClientMutationsCode */
// builds params for either add or update mutations
function buildMutationParams(table, mutationType) {
- let query = `const ${mutationType}${table.type}Mutation = gql\`\n${tab}mutation(`;
+ let query = `const ${mutationType}${table.type}Mutation = gql\`\n${tab}mutation(`
- let firstLoop = true;
+ let firstLoop = true
for (const fieldId in table.fields) {
// if there's an unique id and creating an update mutation, then take in ID
if (fieldId === '0' && mutationType === 'update') {
- if (!firstLoop) query += ', ';
- firstLoop = false;
+ if (!firstLoop) query += ', '
+ firstLoop = false
- query += `$${table.fields[fieldId].name}: ${table.fields[fieldId].type}!`;
+ query += `$${table.fields[fieldId].name}: ${table.fields[fieldId].type}!`
}
if (fieldId !== '0') {
- if (!firstLoop) query += ', ';
- firstLoop = false;
-
- query += `$${table.fields[fieldId].name}: ${checkForMultipleValues(table.fields[fieldId].multipleValues, 'front')}`;
- query += `${checkFieldType(table.fields[fieldId].type)}${checkForMultipleValues(table.fields[fieldId].multipleValues, 'back')}`;
- query += `${checkForRequired(table.fields[fieldId].required)}`;
+ if (!firstLoop) query += ', '
+ firstLoop = false
+
+ query += `$${table.fields[fieldId].name}: ${checkForMultipleValues(
+ table.fields[fieldId].multipleValues,
+ 'front'
+ )}`
+ query += `${checkFieldType(table.fields[fieldId].type)}${checkForMultipleValues(
+ table.fields[fieldId].multipleValues,
+ 'back'
+ )}`
+ query += `${checkForRequired(table.fields[fieldId].required)}`
}
}
- return (query += `) {\n${tab}`);
+ return (query += `) {\n${tab}`)
}
/* HELPER FUNC FOR Controller.convertToGQLClientMutationsCode */
// in case the inputed field type is Number, turn to Int to work with GraphQL
function checkFieldType(fieldType) {
- if (fieldType === 'Number') return 'Int';
- else return fieldType;
+ if (fieldType === 'Number') return 'Int'
+ else return fieldType
}
/* HELPER FUNC FOR Controller.convertToGQLClientMutationsCode */
function buildDeleteMutationParams(table) {
- const idName = table.fields[0].name;
- let query = `const delete${table.type}Mutation = gql\`\n`;
- query += `${tab}mutation($${idName}: ${table.fields[0].type}!){\n`;
- query += `${tab}${tab}delete${table.type}(${idName}: $${idName}){\n`;
- return query;
+ const idName = table.fields[0].name
+ let query = `const delete${table.type}Mutation = gql\`\n`
+ query += `${tab}mutation($${idName}: ${table.fields[0].type}!){\n`
+ query += `${tab}${tab}delete${table.type}(${idName}: $${idName}){\n`
+ return query
}
/* HELPER FUNC FOR Controller.convertToGQLClientMutationsCode */
function checkForMultipleValues(multipleValues, position) {
if (multipleValues) {
if (position === 'front') {
- return '[';
+ return '['
}
- return ']';
+ return ']'
}
- return '';
+ return ''
}
/* HELPER FUNC FOR Controller.convertToGQLClientMutationsCode */
function checkForRequired(required) {
if (required) {
- return '!';
+ return '!'
}
- return '';
+ return ''
}
/* HELPER FUNC FOR Controller.convertToGQLClientMutationsCode */
function buildTypeParams(table, mutationType) {
- let query = `${tab}${mutationType}${table.type}(`;
+ let query = `${tab}${mutationType}${table.type}(`
- let firstLoop = true;
+ let firstLoop = true
for (const fieldId in table.fields) {
// if there's an unique id and creating an update mutation, then take in ID
if (fieldId === '0' && mutationType === 'update') {
- if (!firstLoop) query += ', ';
- firstLoop = false;
- query += `${table.fields[fieldId].name}: $${table.fields[fieldId].name}`;
+ if (!firstLoop) query += ', '
+ firstLoop = false
+ query += `${table.fields[fieldId].name}: $${table.fields[fieldId].name}`
}
if (fieldId !== '0') {
- if (!firstLoop) query += ', ';
- firstLoop = false;
+ if (!firstLoop) query += ', '
+ firstLoop = false
- query += `${table.fields[fieldId].name}: $${table.fields[fieldId].name}`;
+ query += `${table.fields[fieldId].name}: $${table.fields[fieldId].name}`
}
}
- return (query += `) {\n`);
+ return (query += `) {\n`)
}
/* HELPER FUNC FOR Controller.convertToGQLClientMutationsCode */
function buildReturnValues(table) {
- let query = '';
+ let query = ''
for (const fieldId in table.fields) {
- query += `${tab}${tab}${tab}${table.fields[fieldId].name}\n`;
+ query += `${tab}${tab}${tab}${table.fields[fieldId].name}\n`
}
- return (query += `${tab}${tab}}\n${tab}}\n\`\n\n`);
+ return (query += `${tab}${tab}}\n${tab}}\n\`\n\n`)
}
-module.exports = Controller;
+module.exports = Controller
diff --git a/server/controllers/GQLServerController.js b/server/controllers/GQLServerController.js
index 7368212..837f39a 100644
--- a/server/controllers/GQLServerController.js
+++ b/server/controllers/GQLServerController.js
@@ -1,93 +1,95 @@
-const Controller = {};
+const Controller = {}
-const tab = ` `;
+const tab = ` `
/* MAIN FUNCTION THAT CALLS ALL OTHER HELPER FUNCTIONS */
Controller.convertToGQLServerCode = (req, res, next) => {
try {
- const databases = res.locals.preppedForGQL;
+ const databases = res.locals.preppedForGQL
- let query = '';
- query += "const graphql = require('graphql');\n";
+ let query = ''
+ query += "const graphql = require('graphql');\n"
for (const databaseIndex in databases) {
- const database = databases[databaseIndex];
+ const database = databases[databaseIndex]
// database.data is same as database.tables
- query += buildRequireStatements(database.tables, database.databaseName, database.name);
+ query += buildRequireStatements(database.tables, database.databaseName, database.name)
}
- query += buildGraphqlVariables();
+ query += buildGraphqlVariables()
// BUILD TYPE SCHEMA
for (const databaseIndex in databases) {
- const tables = databases[databaseIndex].tables;
- const databaseName = databases[databaseIndex].databaseName;
+ const tables = databases[databaseIndex].tables
+ const databaseName = databases[databaseIndex].databaseName
for (const tableIndex in tables) {
- query += buildGraphqlTypeSchema(tables[tableIndex], tables, databaseName);
+ query += buildGraphqlTypeSchema(tables[tableIndex], tables, databaseName)
}
}
// BUILD ROOT QUERY
- query += `const RootQuery = new GraphQLObjectType({\n${tab}name: 'RootQueryType',\n${tab}fields: {\n`;
+ query += `const RootQuery = new GraphQLObjectType({\n${tab}name: 'RootQueryType',\n${tab}fields: {\n`
- let firstRootLoop = true;
+ let firstRootLoop = true
for (const databaseIndex in databases) {
- const tables = databases[databaseIndex].tables;
- const databaseName = databases[databaseIndex].databaseName;
+ const tables = databases[databaseIndex].tables
+ const databaseName = databases[databaseIndex].databaseName
for (const tableIndex in tables) {
- if (!firstRootLoop) query += ',\n';
- firstRootLoop = false;
+ if (!firstRootLoop) query += ',\n'
+ firstRootLoop = false
- query += buildGraphqlRootQuery(tables[tableIndex], databaseName);
+ query += buildGraphqlRootQuery(tables[tableIndex], databaseName)
}
}
- query += `\n${tab}}\n});\n\n`;
+ query += `\n${tab}}\n});\n\n`
// BUILD MUTATIONS
- query += `const Mutation = new GraphQLObjectType({\n${tab}name: 'Mutation',\n${tab}fields: {\n`;
+ query += `const Mutation = new GraphQLObjectType({\n${tab}name: 'Mutation',\n${tab}fields: {\n`
- let firstMutationLoop = true;
+ let firstMutationLoop = true
for (const databaseIndex in databases) {
- const tables = databases[databaseIndex].tables;
- const databaseName = databases[databaseIndex].databaseName;
+ const tables = databases[databaseIndex].tables
+ const databaseName = databases[databaseIndex].databaseName
for (const tableIndex in tables) {
- if (!firstMutationLoop) query += ',\n';
- firstMutationLoop = false;
+ if (!firstMutationLoop) query += ',\n'
+ firstMutationLoop = false
- query += buildGraphqlMutationQuery(tables[tableIndex], databaseName);
+ query += buildGraphqlMutationQuery(tables[tableIndex], databaseName)
}
}
- query += `\n${tab}}\n});\n\n`;
+ query += `\n${tab}}\n});\n\n`
- query += `module.exports = new GraphQLSchema({\n${tab}query: RootQuery,\n${tab}mutation: Mutation\n});`;
+ query += `module.exports = new GraphQLSchema({\n${tab}query: RootQuery,\n${tab}mutation: Mutation\n});`
// return query;
- res.locals.GQLServerCode = query;
- return next();
+ res.locals.GQLServerCode = query
+ return next()
} catch (error) {
const errObj = {
log: `Error in server middleware @ parseGraphqlServer: ${error}`,
status: 400,
message: {
- err: 'Unable to parse Graphql Server Code',
- },
- };
- return next(errObj);
+ err: 'Unable to parse Graphql Server Code'
+ }
+ }
+ return next(errObj)
}
-};
+}
/** EXPLAINS FUNC BELOW...
* @param {String} database - Represents the database selected (MongoDB, MySQL, or PostgreSQL)
* @returns {String} - All the require statements needed for the GraphQL server.
*/
function buildRequireStatements(tables, database, name) {
- let requireStatements = '';
+ let requireStatements = ''
if (database === 'MongoDB') {
for (const tableIndex in tables) {
- requireStatements += `const ${tables[tableIndex].type} = require('../db/${name}/${tables[tableIndex].type.toLowerCase()}.js');\n`;
+ requireStatements += `const ${tables[tableIndex].type} = require('../db/${name}/${tables[
+ tableIndex
+ ].type.toLowerCase()}.js');\n`
}
} else {
- requireStatements += `const pool = require('../db/${name}/sql_pool.js');\n`;
+ requireStatements += `const pool = require('../db/${name}/sql_pool.js');\n`
}
- return requireStatements;
+ return requireStatements
}
/** EXPLAINS FUNC BELOW...
@@ -105,7 +107,7 @@ const {
GraphQLList,
GraphQLNonNull
} = graphql;
- \n`;
+ \n`
}
/** EXPLAINS FUNC BELOW...
@@ -115,11 +117,11 @@ const {
* @returns {String} - The GraphQL type code for the inputted table
*/
function buildGraphqlTypeSchema(table, tables, database) {
- let query = `const ${table.type}Type = new GraphQLObjectType({\n`;
- query += `${tab}name: '${table.type}',\n`;
- query += `${tab}fields: () => ({`;
- query += buildGraphQLTypeFields(table, tables, database);
- return (query += `\n${tab}})\n});\n\n`);
+ let query = `const ${table.type}Type = new GraphQLObjectType({\n`
+ query += `${tab}name: '${table.type}',\n`
+ query += `${tab}fields: () => ({`
+ query += buildGraphQLTypeFields(table, tables, database)
+ return (query += `\n${tab}})\n});\n\n`)
}
/** EXPLAINS FUNC BELOW...
@@ -129,37 +131,37 @@ function buildGraphqlTypeSchema(table, tables, database) {
* @returns {String} - each field for the GraphQL type.
*/
function buildGraphQLTypeFields(table, tables, database) {
- let query = '';
- let firstLoop = true;
+ let query = ''
+ let firstLoop = true
for (let fieldIndex in table.fields) {
- if (!firstLoop) query += ',';
- firstLoop = false;
+ if (!firstLoop) query += ','
+ firstLoop = false
- query += `\n${tab}${tab}${buildFieldItem(table.fields[fieldIndex])}`;
+ query += `\n${tab}${tab}${buildFieldItem(table.fields[fieldIndex])}`
// check if the field has a relation to another field
if (table.fields[fieldIndex].relation.tableIndex > -1) {
- query += createSubQuery(table.fields[fieldIndex], tables, database);
+ query += createSubQuery(table.fields[fieldIndex], tables, database)
}
// check if the field is a relation for another field
- const refBy = table.fields[fieldIndex].refBy;
+ const refBy = table.fields[fieldIndex].refBy
if (Array.isArray(refBy)) {
refBy.forEach((value) => {
- const parsedValue = value.split('.');
+ const parsedValue = value.split('.')
const field = {
name: table.fields[fieldIndex].name,
relation: {
tableIndex: parsedValue[0],
fieldIndex: parsedValue[1],
refType: parsedValue[2],
- type: table.fields[fieldIndex].type,
- },
- };
- query += createSubQuery(field, tables, database);
- });
+ type: table.fields[fieldIndex].type
+ }
+ }
+ query += createSubQuery(field, tables, database)
+ })
}
}
- return query;
+ return query
}
/** EXPLAINS FUNC BELOW...
@@ -167,9 +169,15 @@ function buildGraphQLTypeFields(table, tables, database) {
* @returns {String} - a field item (ex: 'id: { type: GraphQLID }')
*/
function buildFieldItem(field) {
- return `${field.name}: { type: ${checkForRequired(field.required, 'front')}${checkForMultipleValues(field.multipleValues, 'front')}${tableTypeToGraphqlType(
+ return `${field.name}: { type: ${checkForRequired(
+ field.required,
+ 'front'
+ )}${checkForMultipleValues(field.multipleValues, 'front')}${tableTypeToGraphqlType(
field.type
- )}${checkForMultipleValues(field.multipleValues, 'back')}${checkForRequired(field.required, 'back')} }`;
+ )}${checkForMultipleValues(field.multipleValues, 'back')}${checkForRequired(
+ field.required,
+ 'back'
+ )} }`
}
/** EXPLAINS FUNC BELOW...
@@ -179,17 +187,17 @@ function buildFieldItem(field) {
function tableTypeToGraphqlType(type) {
switch (type) {
case 'ID':
- return 'GraphQLID';
+ return 'GraphQLID'
case 'String':
- return 'GraphQLString';
+ return 'GraphQLString'
case 'Number':
- return 'GraphQLInt';
+ return 'GraphQLInt'
case 'Boolean':
- return 'GraphQLBoolean';
+ return 'GraphQLBoolean'
case 'Float':
- return 'GraphQLFloat';
+ return 'GraphQLFloat'
default:
- return 'GraphQLString';
+ return 'GraphQLString'
}
}
@@ -198,9 +206,9 @@ function tableTypeToGraphqlType(type) {
* @returns {String} - The string inputted, but with the first letter capitalized and the rest lowercased
*/
function toTitleCase(refTypeName) {
- let name = refTypeName[0].toUpperCase();
- name += refTypeName.slice(1).toLowerCase();
- return name;
+ let name = refTypeName[0].toUpperCase()
+ name += refTypeName.slice(1).toLowerCase()
+ return name
}
/** EXPLAINS FUNC BELOW...
@@ -210,32 +218,39 @@ function toTitleCase(refTypeName) {
* @returns {String} - Builds a sub type for any field with a relation.
*/
function createSubQuery(field, tables, database) {
- const refTypeName = tables[field.relation.tableIndex].type;
- const refFieldName = tables[field.relation.tableIndex].fields[field.relation.fieldIndex].name;
- const refFieldType = tables[field.relation.tableIndex].fields[field.relation.fieldIndex].type;
- let query = `,\n${tab}${tab}${createSubQueryName(field, refTypeName)}: {\n${tab}${tab}${tab}type: `;
+ const refTypeName = tables[field.relation.tableIndex].type
+ const refFieldName = tables[field.relation.tableIndex].fields[field.relation.fieldIndex].name
+ const refFieldType = tables[field.relation.tableIndex].fields[field.relation.fieldIndex].type
+ let query = `,\n${tab}${tab}${createSubQueryName(
+ field,
+ refTypeName
+ )}: {\n${tab}${tab}${tab}type: `
if (field.relation.refType === 'one to many' || field.relation.refType === 'many to many') {
- query += `new GraphQLList(${refTypeName}Type),`;
+ query += `new GraphQLList(${refTypeName}Type),`
} else {
- query += `${refTypeName}Type,`;
+ query += `${refTypeName}Type,`
}
- query += `\n${tab}${tab}${tab}resolve(parent, args) {\n`;
+ query += `\n${tab}${tab}${tab}resolve(parent, args) {\n`
if (database === 'MongoDB') {
- query += `${tab}${tab}${tab}${tab}return ${refTypeName}.${findDbSearchMethod(refFieldName, refFieldType, field.relation.refType)}`;
- query += `(${createSearchObject(refFieldName, refFieldType, field)});\n`;
- query += `${tab}${tab}${tab}}\n`;
- query += `${tab}${tab}}`;
+ query += `${tab}${tab}${tab}${tab}return ${refTypeName}.${findDbSearchMethod(
+ refFieldName,
+ refFieldType,
+ field.relation.refType
+ )}`
+ query += `(${createSearchObject(refFieldName, refFieldType, field)});\n`
+ query += `${tab}${tab}${tab}}\n`
+ query += `${tab}${tab}}`
}
if (database === 'MySQL' || database === 'PostgreSQL') {
- query += `${tab}${tab}${tab}${tab}const sql = \`SELECT * FROM "${refTypeName}" WHERE "${refFieldName}" = '\${parent.${field.name}}';\`\n`;
- query += buildSQLPoolQuery(field.relation.refType);
- query += `${tab}${tab}${tab}}\n`;
- query += `${tab}${tab}}`;
+ query += `${tab}${tab}${tab}${tab}const sql = \`SELECT * FROM "${refTypeName}" WHERE "${refFieldName}" = '\${parent.${field.name}}';\`\n`
+ query += buildSQLPoolQuery(field.relation.refType)
+ query += `${tab}${tab}${tab}}\n`
+ query += `${tab}${tab}}`
}
- return query;
+ return query
}
/** EXPLAINS FUNC BELOW...
@@ -243,14 +258,14 @@ function createSubQuery(field, tables, database) {
* @returns {String} - the code for a SQL pool query.
*/
function buildSQLPoolQuery(refType) {
- let rows = '';
- if (refType === 'one to one' || refType === 'many to one') rows = 'rows[0]';
- else rows = 'rows';
-
- let query = `${tab}${tab}${tab}${tab}return pool.query(sql)\n`;
- query += `${tab}${tab}${tab}${tab}${tab}.then(res => res.${rows})\n`;
- query += `${tab}${tab}${tab}${tab}${tab}.catch(err => console.log('Error: ', err))\n`;
- return query;
+ let rows = ''
+ if (refType === 'one to one' || refType === 'many to one') rows = 'rows[0]'
+ else rows = 'rows'
+
+ let query = `${tab}${tab}${tab}${tab}return pool.query(sql)\n`
+ query += `${tab}${tab}${tab}${tab}${tab}.then(res => res.${rows})\n`
+ query += `${tab}${tab}${tab}${tab}${tab}.catch(err => console.log('Error: ', err))\n`
+ return query
}
/** EXPLAINS FUNC BELOW...
@@ -259,202 +274,209 @@ function buildSQLPoolQuery(refType) {
* @returns {String} - root query code to find an individual type
*/
function createFindByIdQuery(table, database) {
- const idFieldName = table.fields[0].name;
- let query = `,\n${tab}${tab}${table.type.toLowerCase()}: {\n`;
- query += `${tab}${tab}${tab}type: ${table.type}Type,\n`;
- query += `${tab}${tab}${tab}args: { ${idFieldName}: { type: ${tableTypeToGraphqlType(table.fields[0].type)}}},\n`;
- query += `${tab}${tab}${tab}resolve(parent, args) {\n`;
+ const idFieldName = table.fields[0].name
+ let query = `,\n${tab}${tab}${table.type.toLowerCase()}: {\n`
+ query += `${tab}${tab}${tab}type: ${table.type}Type,\n`
+ query += `${tab}${tab}${tab}args: { ${idFieldName}: { type: ${tableTypeToGraphqlType(
+ table.fields[0].type
+ )}}},\n`
+ query += `${tab}${tab}${tab}resolve(parent, args) {\n`
if (database === 'MongoDB') {
- query += `${tab}${tab}${tab}${tab}return ${table.type}.findById(args.id);\n`;
+ query += `${tab}${tab}${tab}${tab}return ${table.type}.findById(args.id);\n`
}
if (database === 'MySQL' || database === 'PostgreSQL') {
- query += `${tab}${tab}${tab}${tab}const sql = \`SELECT * FROM "${table.type}" WHERE ${idFieldName} = '\${args.id}';\`;\n`;
- query += buildSQLPoolQuery('one to one');
+ query += `${tab}${tab}${tab}${tab}const sql = \`SELECT * FROM "${table.type}" WHERE ${idFieldName} = '\${args.id}';\`;\n`
+ query += buildSQLPoolQuery('one to one')
}
- return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`);
+ return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`)
}
function createSubQueryName(field, refTypeName) {
switch (field.relation.refType) {
case 'one to one':
- return `related${toTitleCase(refTypeName)}`;
+ return `related${toTitleCase(refTypeName)}`
case 'one to many':
- return `everyRelated${toTitleCase(refTypeName)}`;
+ return `everyRelated${toTitleCase(refTypeName)}`
case 'many to one':
- return `related${toTitleCase(refTypeName)}`;
+ return `related${toTitleCase(refTypeName)}`
case 'many to many':
- return `everyRelated${toTitleCase(refTypeName)}`;
+ return `everyRelated${toTitleCase(refTypeName)}`
default:
- return `everyRelated${toTitleCase(refTypeName)}`;
+ return `everyRelated${toTitleCase(refTypeName)}`
}
}
function findDbSearchMethod(refFieldName, refFieldType, refType) {
- if (refFieldName === 'id' || refFieldType === 'ID') return 'findById';
- else if (refType === 'one to one') return 'findOne';
- else return 'find';
+ if (refFieldName === 'id' || refFieldType === 'ID') return 'findById'
+ else if (refType === 'one to one') return 'findOne'
+ else return 'find'
}
function createSearchObject(refFieldName, refFieldType, field) {
if (refFieldName === 'id' || refFieldType === 'ID') {
- return `parent.${field.name}`;
+ return `parent.${field.name}`
} else {
- return `{ ${refFieldName}: parent.${field.name} }`;
+ return `{ ${refFieldName}: parent.${field.name} }`
}
}
function buildGraphqlRootQuery(table, database) {
- let query = '';
+ let query = ''
- query += createFindAllRootQuery(table, database);
+ query += createFindAllRootQuery(table, database)
if (!!table.fields[0]) {
- query += createFindByIdQuery(table, database);
+ query += createFindByIdQuery(table, database)
}
- return query;
+ return query
}
function createFindAllRootQuery(table, database) {
- let query = `${tab}${tab}every${toTitleCase(table.type)}: {\n`;
- query += `${tab}${tab}${tab}type: new GraphQLList(${table.type}Type),\n`;
- query += `${tab}${tab}${tab}resolve() {\n`;
+ let query = `${tab}${tab}every${toTitleCase(table.type)}: {\n`
+ query += `${tab}${tab}${tab}type: new GraphQLList(${table.type}Type),\n`
+ query += `${tab}${tab}${tab}resolve() {\n`
if (database === 'MongoDB') {
- query += `${tab}${tab}${tab}${tab}return ${table.type}.find({});\n`;
+ query += `${tab}${tab}${tab}${tab}return ${table.type}.find({});\n`
}
if (database === 'MySQL' || database === 'PostgreSQL') {
- query += `${tab}${tab}${tab}${tab}const sql = \`SELECT * FROM "${table.type}";\`\n`;
- query += buildSQLPoolQuery('many');
+ query += `${tab}${tab}${tab}${tab}const sql = \`SELECT * FROM "${table.type}";\`\n`
+ query += buildSQLPoolQuery('many')
}
- return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`);
+ return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`)
}
function buildGraphqlMutationQuery(table, database) {
- let string = ``;
- string += `${addMutation(table, database)}`;
+ let string = ``
+ string += `${addMutation(table, database)}`
if (table.fields[0]) {
- string += `,\n${updateMutation(table, database)},\n`;
- string += `${deleteMutation(table, database)}`;
+ string += `,\n${updateMutation(table, database)},\n`
+ string += `${deleteMutation(table, database)}`
}
- return string;
+ return string
}
function buildSQLPoolMutation() {
- let string = ``;
- string += `${tab}${tab}${tab}${tab}return pool.connect()\n`;
- string += `${tab}${tab}${tab}${tab}${tab}.then(client => {\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}return client.query(sql)\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}.then(res => {\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}client.release();\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}return res.rows[0];\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}})\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}.catch(err => {\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}client.release();\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}console.log('Error: ', err);\n`;
- string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}})\n`;
- string += `${tab}${tab}${tab}${tab}${tab}})\n`;
- return string;
+ let string = ``
+ string += `${tab}${tab}${tab}${tab}return pool.connect()\n`
+ string += `${tab}${tab}${tab}${tab}${tab}.then(client => {\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}return client.query(sql)\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}.then(res => {\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}client.release();\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}return res.rows[0];\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}})\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}.catch(err => {\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}client.release();\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}console.log('Error: ', err);\n`
+ string += `${tab}${tab}${tab}${tab}${tab}${tab}${tab}})\n`
+ string += `${tab}${tab}${tab}${tab}${tab}})\n`
+ return string
}
function addMutation(table, database) {
- let query = `${tab}${tab}add${table.type}: {\n`;
- query += `${tab}${tab}${tab}type: ${table.type}Type,\n`;
- query += `${tab}${tab}${tab}args: {\n`;
+ let query = `${tab}${tab}add${table.type}: {\n`
+ query += `${tab}${tab}${tab}type: ${table.type}Type,\n`
+ query += `${tab}${tab}${tab}args: {\n`
- let firstLoop = true;
+ let firstLoop = true
for (const fieldIndex in table.fields) {
- if (!firstLoop) query += ',\n';
- firstLoop = false;
+ if (!firstLoop) query += ',\n'
+ firstLoop = false
- query += `${tab}${tab}${tab}${tab}${buildFieldItem(table.fields[fieldIndex])}`;
+ query += `${tab}${tab}${tab}${tab}${buildFieldItem(table.fields[fieldIndex])}`
}
- query += `\n${tab}${tab}${tab}},\n`;
- query += `${tab}${tab}${tab}resolve(parent, args) {\n`;
+ query += `\n${tab}${tab}${tab}},\n`
+ query += `${tab}${tab}${tab}resolve(parent, args) {\n`
if (database === 'MongoDB') {
- query += `${tab}${tab}${tab}${tab}const ${table.type.toLowerCase()} = new ${table.type}(args);\n`;
- query += `${tab}${tab}${tab}${tab}return ${table.type.toLowerCase()}.save();\n`;
+ query += `${tab}${tab}${tab}${tab}const ${table.type.toLowerCase()} = new ${
+ table.type
+ }(args);\n`
+ query += `${tab}${tab}${tab}${tab}return ${table.type.toLowerCase()}.save();\n`
}
if (database === 'MySQL' || database === 'PostgreSQL') {
- query += `${tab}${tab}${tab}${tab}const columns = Object.keys(args).map(el => \`"\${el}"\`);\n`;
- query += `${tab}${tab}${tab}${tab}const values = Object.values(args).map(el => \`'\${el}'\`);\n`;
- query += `${tab}${tab}${tab}${tab}const sql = \`INSERT INTO "${table.type}" (\${columns}) VALUES (\${values}) RETURNING *\`;\n`;
- query += buildSQLPoolMutation();
+ query += `${tab}${tab}${tab}${tab}const columns = Object.keys(args).map(el => \`"\${el}"\`);\n`
+ query += `${tab}${tab}${tab}${tab}const values = Object.values(args).map(el => \`'\${el}'\`);\n`
+ query += `${tab}${tab}${tab}${tab}const sql = \`INSERT INTO "${table.type}" (\${columns}) VALUES (\${values}) RETURNING *\`;\n`
+ query += buildSQLPoolMutation()
}
- return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`);
+ return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`)
}
function updateMutation(table, database) {
- let query = `${tab}${tab}update${table.type}: {\n${tab}${tab}${tab}type: ${table.type}Type,\n${tab}${tab}${tab}args: {\n`;
+ let query = `${tab}${tab}update${table.type}: {\n${tab}${tab}${tab}type: ${table.type}Type,\n${tab}${tab}${tab}args: {\n`
- let firstLoop = true;
+ let firstLoop = true
for (const fieldIndex in table.fields) {
- if (!firstLoop) query += ',\n';
- firstLoop = false;
+ if (!firstLoop) query += ',\n'
+ firstLoop = false
- query += `${tab}${tab}${tab}${tab}${buildFieldItem(table.fields[fieldIndex])}`;
+ query += `${tab}${tab}${tab}${tab}${buildFieldItem(table.fields[fieldIndex])}`
}
- query += `\n${tab}${tab}${tab}},\n${tab}${tab}${tab}resolve(parent, args) {\n`;
+ query += `\n${tab}${tab}${tab}},\n${tab}${tab}${tab}resolve(parent, args) {\n`
- if (database === 'MongoDB') query += `${tab}${tab}${tab}${tab}return ${table.type}.findByIdAndUpdate(args.id, args);\n`;
+ if (database === 'MongoDB')
+ query += `${tab}${tab}${tab}${tab}return ${table.type}.findByIdAndUpdate(args.id, args);\n`
if (database === 'MySQL' || database === 'PostgreSQL') {
- query += `${tab}${tab}${tab}${tab}let updateValues = '';\n`;
- query += `${tab}${tab}${tab}${tab}for (const prop in args) {\n`;
- query += `${tab}${tab}${tab}${tab}${tab}if (updateValues.length > 0) updateValues += \`, \`;\n`;
- query += `${tab}${tab}${tab}${tab}${tab}updateValues += \`"\${prop}" = '\${args[prop]}' \`;\n`;
- query += `${tab}${tab}${tab}${tab}}\n`;
- query += `${tab}${tab}${tab}${tab}const sql = \`UPDATE "${table.type}" SET \${updateValues} WHERE id = '\${args.id}' RETURNING *;\`\n`;
- query += buildSQLPoolMutation();
+ query += `${tab}${tab}${tab}${tab}let updateValues = '';\n`
+ query += `${tab}${tab}${tab}${tab}for (const prop in args) {\n`
+ query += `${tab}${tab}${tab}${tab}${tab}if (updateValues.length > 0) updateValues += \`, \`;\n`
+ query += `${tab}${tab}${tab}${tab}${tab}updateValues += \`"\${prop}" = '\${args[prop]}' \`;\n`
+ query += `${tab}${tab}${tab}${tab}}\n`
+ query += `${tab}${tab}${tab}${tab}const sql = \`UPDATE "${table.type}" SET \${updateValues} WHERE id = '\${args.id}' RETURNING *;\`\n`
+ query += buildSQLPoolMutation()
}
- return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`);
+ return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`)
}
function deleteMutation(table, database) {
- const idFieldName = table.fields[0].name;
- let query = `${tab}${tab}delete${table.type}: {\n`;
- query += `${tab}${tab}${tab}type: ${table.type}Type,\n`;
- query += `${tab}${tab}${tab}args: { ${idFieldName}: { type: ${tableTypeToGraphqlType(table.fields[0].type)}}},\n`;
- query += `${tab}${tab}${tab}resolve(parent, args) {\n`;
+ const idFieldName = table.fields[0].name
+ let query = `${tab}${tab}delete${table.type}: {\n`
+ query += `${tab}${tab}${tab}type: ${table.type}Type,\n`
+ query += `${tab}${tab}${tab}args: { ${idFieldName}: { type: ${tableTypeToGraphqlType(
+ table.fields[0].type
+ )}}},\n`
+ query += `${tab}${tab}${tab}resolve(parent, args) {\n`
if (database === 'MongoDB') {
- query += `${tab}${tab}${tab}${tab}return ${table.type}.findByIdAndRemove(args.id);\n`;
+ query += `${tab}${tab}${tab}${tab}return ${table.type}.findByIdAndRemove(args.id);\n`
}
if (database === 'MySQL' || database === 'PostgreSQL') {
- query += `${tab}${tab}${tab}${tab}const sql = \`DELETE FROM "${table.type}" WHERE id = '\${args.id}' RETURNING *;\`\n`;
- query += buildSQLPoolMutation();
+ query += `${tab}${tab}${tab}${tab}const sql = \`DELETE FROM "${table.type}" WHERE id = '\${args.id}' RETURNING *;\`\n`
+ query += buildSQLPoolMutation()
}
- return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`);
+ return (query += `${tab}${tab}${tab}}\n${tab}${tab}}`)
}
function checkForRequired(required, position) {
if (required) {
if (position === 'front') {
- return 'new GraphQLNonNull(';
+ return 'new GraphQLNonNull('
}
- return ')';
+ return ')'
}
- return '';
+ return ''
}
function checkForMultipleValues(multipleValues, position) {
if (multipleValues) {
if (position === 'front') {
- return 'new GraphQLList(';
+ return 'new GraphQLList('
}
- return ')';
+ return ')'
}
- return '';
+ return ''
}
-module.exports = Controller;
+module.exports = Controller
diff --git a/server/controllers/MongoDBController.js b/server/controllers/MongoDBController.js
index 1a377c5..cd7a54b 100644
--- a/server/controllers/MongoDBController.js
+++ b/server/controllers/MongoDBController.js
@@ -1,14 +1,14 @@
-const mongoose = require('mongoose');
-const { MongoClient } = require('mongodb');
+const mongoose = require('mongoose')
+const { MongoClient } = require('mongodb')
-const Controller = {};
+const Controller = {}
/* CONNECT TO MONGO AND GET COLLECTION NAMES MIDDLEWARE */
Controller.connectToMongo = async (req, res, next) => {
- const MONGO_URI = res.locals.userURIDecrypted;
+ const MONGO_URI = res.locals.userURIDecrypted
try {
- const collectionNames = [];
+ const collectionNames = []
/* CONNECT TO MONGO DB, TRY FOR 5 SECONDS */
await mongoose.connect(MONGO_URI, { serverSelectionTimeoutMS: 5000 }).then(() => {
@@ -19,82 +19,84 @@ Controller.connectToMongo = async (req, res, next) => {
log: `Error caught in server middleware @ connectToMongo: ${err}`,
status: 400,
message: {
- err: 'Unable to get collection names from Mongo DB',
- },
- };
- return next(errObj);
+ err: 'Unable to get collection names from Mongo DB'
+ }
+ }
+ return next(errObj)
} else {
/* GET MONGODB NAMES */
- res.locals.DBname = mongoose.connection.db.namespace;
- names.forEach((el) => collectionNames.push(el.name));
- res.locals.collectionNames = collectionNames;
- mongoose.connection.close();
- return next();
+ res.locals.DBname = mongoose.connection.db.namespace
+ names.forEach((el) => collectionNames.push(el.name))
+ res.locals.collectionNames = collectionNames
+ mongoose.connection.close()
+ return next()
}
- });
- });
+ })
+ })
} catch (error) {
const errObj = {
log: `Error caught in server middleware @ connectToMongo: ${error}`,
status: 400,
message: {
- err: 'Unable to connect to MongoDB Database Please enter a valid Connection String / Make sure ALL IP Addresses have access',
- },
- };
- return next(errObj);
+ err: 'Unable to connect to MongoDB Database Please enter a valid Connection String / Make sure ALL IP Addresses have access'
+ }
+ }
+ return next(errObj)
}
-};
+}
/* GET MONGO DOCUMENTS FOR EACH COLLECTION NAME MIDDLEWARE */
Controller.getMongoDocuments = async (req, res, next) => {
- const MONGO_URI = res.locals.userURIDecrypted;
+ const MONGO_URI = res.locals.userURIDecrypted
// Mongo Databse Name
- const MONGO_NAME = res.locals.DBname;
+ const MONGO_NAME = res.locals.DBname
// Array of collections names
- const collectionNames = res.locals.collectionNames;
+ const collectionNames = res.locals.collectionNames
try {
- const client = new MongoClient(MONGO_URI);
+ const client = new MongoClient(MONGO_URI)
- await client.connect();
+ await client.connect()
// console.log('Connected to MongoDB...');
- const db = client.db(MONGO_NAME);
+ const db = client.db(MONGO_NAME)
/* CREATE MONGO SCHEMA FROM DB */
- const MongoSchema = { tables: {} };
+ const MongoSchema = { tables: {} }
- let collection;
- let documents;
+ let collection
+ let documents
/* LOOP THROUGH COLLECTION NAMES AND FIND ALL DOCUMENTS + POPULATE MONGO SCHEMA */
for (let i = 0; i < collectionNames.length; i++) {
- MongoSchema.tables[collectionNames[i]] = { columns: {} };
- collection = db.collection(collectionNames[i]);
- documents = await collection.find({}).toArray();
+ MongoSchema.tables[collectionNames[i]] = { columns: {} }
+ collection = db.collection(collectionNames[i])
+ documents = await collection.find({}).toArray()
for (let j = 0; j < documents.length; j++) {
- MongoSchema.tables[collectionNames[i]].primaryKey = documents[j]._id;
+ MongoSchema.tables[collectionNames[i]].primaryKey = documents[j]._id
for (const key in documents[i]) {
- MongoSchema.tables[collectionNames[i]].columns[key] = { dataType: typeof documents[i][key] };
+ MongoSchema.tables[collectionNames[i]].columns[key] = {
+ dataType: typeof documents[i][key]
+ }
}
}
}
- res.locals.MongoSchema = MongoSchema;
- return next();
+ res.locals.MongoSchema = MongoSchema
+ return next()
} catch (error) {
const errObj = {
log: `Error caught in server middleware @ getMongoDocuments: ${error}`,
status: 400,
message: {
- err: 'Unable to get MongoDB documents',
- },
- };
- return next(errObj);
+ err: 'Unable to get MongoDB documents'
+ }
+ }
+ return next(errObj)
}
-};
+}
/* CONVERT MONGODB INFO TO GQLServerController READABLE OBJECT MIDDLEWARE */
Controller.MongoPrepForGQL = (req, res, next) => {
@@ -103,20 +105,23 @@ Controller.MongoPrepForGQL = (req, res, next) => {
0: {
name: res.locals.DBname,
databaseName: 'MongoDB',
- tables: {},
- },
- };
+ tables: {}
+ }
+ }
/* LOOP THROUGH TABLES AND POPULATE res.locals.preppedForGQL
WITH APPROPRIATE DATA */
- const { tables } = res.locals.MongoSchema;
- let tableCount = 0;
- let fieldCount = 0;
+ const { tables } = res.locals.MongoSchema
+ let tableCount = 0
+ let fieldCount = 0
for (const table in tables) {
- let tableCache = (res.locals.preppedForGQL[0].tables[tableCount] = { type: table, fields: {} });
+ let tableCache = (res.locals.preppedForGQL[0].tables[tableCount] = {
+ type: table,
+ fields: {}
+ })
- const tableFields = tables[table].columns;
+ const tableFields = tables[table].columns
/* LOOP THROUGH FIELDS OF TABLE AND POPULATE res.locals.preppedForGQL WITH APPROPRIATE DATA */
for (const field in tableFields) {
@@ -131,28 +136,28 @@ Controller.MongoPrepForGQL = (req, res, next) => {
relation: {
tableIndex: -1,
fieldIndex: -1,
- refType: '',
+ refType: ''
},
- refBy: {},
- };
- fieldCount++;
+ refBy: {}
+ }
+ fieldCount++
}
- fieldCount = 0;
- tableCount++;
+ fieldCount = 0
+ tableCount++
}
- return next();
+ return next()
} catch (error) {
const errObj = {
log: `Error caught in server middleware @ MongoPrepForGQL: ${error}`,
status: 400,
message: {
- err: 'Unable to prep MongoSchema for GQL conversion',
- },
- };
- return next(errObj);
+ err: 'Unable to prep MongoSchema for GQL conversion'
+ }
+ }
+ return next(errObj)
}
-};
+}
-module.exports = Controller;
+module.exports = Controller
diff --git a/server/controllers/SQLController.js b/server/controllers/SQLController.js
index 1c47ea4..d40d239 100644
--- a/server/controllers/SQLController.js
+++ b/server/controllers/SQLController.js
@@ -1,54 +1,54 @@
-const { Pool } = require('pg');
-const fs = require('fs');
-const SQLDBAllTablesQuery = fs.readFileSync('server/SQLDBAllTablesQuery.sql', 'utf8');
+const { Pool } = require('pg')
+const fs = require('fs')
+const SQLDBAllTablesQuery = fs.readFileSync('server/SQLDBAllTablesQuery.sql', 'utf8')
-const Controller = {};
+const Controller = {}
/* CONNECT TO POSTGRESQL AND GET DB NAME MIDDLEWARE */
Controller.getSQLDBname = (req, res, next) => {
- const PSQL_URI = res.locals.userURIDecrypted;
+ const PSQL_URI = res.locals.userURIDecrypted
- const db = new Pool({ connectionString: PSQL_URI });
+ const db = new Pool({ connectionString: PSQL_URI })
db.query('SELECT current_database();')
.then((data) => {
- res.locals.DBname = data.rows[0].current_database;
- return next();
+ res.locals.DBname = data.rows[0].current_database
+ return next()
})
.catch((err) => {
const errObj = {
log: `ERROR in server middleware @ getSQLDBname: ${err}`,
status: 400,
message: {
- err: 'Unable to connect to PostgreSQL Database Please enter a valid Connection String',
- },
- };
- return next(errObj);
- });
-};
+ err: 'Unable to connect to PostgreSQL Database Please enter a valid Connection String'
+ }
+ }
+ return next(errObj)
+ })
+}
/* CONNECT TO POSTGRESQL AND GET DB TABLES MIDDLEWARE */
Controller.getSQLTables = (req, res, next) => {
- const PSQL_URI = res.locals.userURIDecrypted;
+ const PSQL_URI = res.locals.userURIDecrypted
- const db = new Pool({ connectionString: PSQL_URI });
+ const db = new Pool({ connectionString: PSQL_URI })
db.query(SQLDBAllTablesQuery)
.then((data) => {
- res.locals.SQLSchema = data.rows[0];
- return next();
+ res.locals.SQLSchema = data.rows[0]
+ return next()
})
.catch((err) => {
const errObj = {
log: `ERROR in server middleware @ getSQLTables: ${err}`,
status: 400,
message: {
- err: 'Unable to connect to PostgreSQL Database Please enter a valid Connection String',
- },
- };
- return next(errObj);
- });
-};
+ err: 'Unable to connect to PostgreSQL Database Please enter a valid Connection String'
+ }
+ }
+ return next(errObj)
+ })
+}
/* CONVERT POSTGRESQL DB INFO TO GQLServerController READABLE OBJECT MIDDLEWARE */
Controller.prepForGQL = (req, res, next) => {
@@ -57,20 +57,23 @@ Controller.prepForGQL = (req, res, next) => {
0: {
name: res.locals.DBname,
databaseName: 'PostgreSQL',
- tables: {},
- },
- };
+ tables: {}
+ }
+ }
/* LOOP THROUGH TABLES AND POPULATE res.locals.preppedForGQL
WITH APPROPRIATE DATA */
- const { tables } = res.locals.SQLSchema;
- let tableCount = 0;
- let fieldCount = 0;
+ const { tables } = res.locals.SQLSchema
+ let tableCount = 0
+ let fieldCount = 0
for (const table in tables) {
- let tableCache = (res.locals.preppedForGQL[0].tables[tableCount] = { type: table, fields: {} });
+ let tableCache = (res.locals.preppedForGQL[0].tables[tableCount] = {
+ type: table,
+ fields: {}
+ })
- const tableFields = tables[table].columns;
+ const tableFields = tables[table].columns
/* LOOP THROUGH FIELDS OF TABLE AND POPULATE res.locals.preppedForGQL WITH APPROPRIATE DATA */
for (const field in tableFields) {
@@ -85,28 +88,28 @@ Controller.prepForGQL = (req, res, next) => {
relation: {
tableIndex: -1,
fieldIndex: -1,
- refType: '',
+ refType: ''
},
- refBy: {},
- };
- fieldCount++;
+ refBy: {}
+ }
+ fieldCount++
}
- fieldCount = 0;
- tableCount++;
+ fieldCount = 0
+ tableCount++
}
- return next();
+ return next()
} catch (error) {
const errObj = {
log: `Error caught in server middleware @ prepForGQL: ${error}`,
status: 400,
message: {
- err: 'Unable to prep SQLSchema for GQL conversion',
- },
- };
- return next(errObj);
+ err: 'Unable to prep SQLSchema for GQL conversion'
+ }
+ }
+ return next(errObj)
}
-};
+}
-module.exports = Controller;
+module.exports = Controller
diff --git a/server/router.js b/server/router.js
index 677ae36..c435bc5 100644
--- a/server/router.js
+++ b/server/router.js
@@ -1,16 +1,23 @@
-const express = require('express');
-const router = express.Router();
-const { decryptURI } = require('./controllers/CryptoJSController');
+const express = require('express')
+const router = express.Router()
+const { decryptURI } = require('./controllers/CryptoJSController')
// const { decryptURI } = require('./controllers/CryptoJSController.ts');
-const { getSQLTables, getSQLDBname, prepForGQL } = require('./controllers/SQLController');
-const { connectToMongo, getMongoDocuments, MongoPrepForGQL } = require('./controllers/MongoDBController');
-const { convertToGQLServerCode } = require('./controllers/GQLServerController');
-const { convertToGQLClientQueriesCode, convertToGQLClientMutationsCode } = require('./controllers/GQLClientController');
+const { getSQLTables, getSQLDBname, prepForGQL } = require('./controllers/SQLController')
+const {
+ connectToMongo,
+ getMongoDocuments,
+ MongoPrepForGQL
+} = require('./controllers/MongoDBController')
+const { convertToGQLServerCode } = require('./controllers/GQLServerController')
+const {
+ convertToGQLClientQueriesCode,
+ convertToGQLClientMutationsCode
+} = require('./controllers/GQLClientController')
router.get('/', (req, res) => {
- res.status(200).send('HELLO FROM THE BACKEND!');
-});
+ res.status(200).send('HELLO FROM THE BACKEND!')
+})
/* ROUTE TO GET DEMO POSTGRESQL DB AND CONVERT TO GRAPHQL SERVER, CLIENT QUERIES AND MUTATIONS CODE */
router.get(
@@ -28,11 +35,11 @@ router.get(
SQLSchema: res.locals.SQLSchema,
GQLServerCode: res.locals.GQLServerCode,
GQLClientQueriesCode: res.locals.GQLClientQueriesCode,
- GQLClientMutationsCode: res.locals.GQLClientMutationsCode,
- };
- res.status(200).json(GQLCode);
+ GQLClientMutationsCode: res.locals.GQLClientMutationsCode
+ }
+ res.status(200).json(GQLCode)
}
-);
+)
/* ROUTE TO GET USER POSTGRESQL DB AND CONVERT TO GRAPHQL SERVER, CLIENT QUERIES AND MUTATIONS CODE */
router.post(
@@ -50,11 +57,11 @@ router.post(
SQLSchema: res.locals.SQLSchema,
GQLServerCode: res.locals.GQLServerCode,
GQLClientQueriesCode: res.locals.GQLClientQueriesCode,
- GQLClientMutationsCode: res.locals.GQLClientMutationsCode,
- };
- res.status(200).json(GQLCode);
+ GQLClientMutationsCode: res.locals.GQLClientMutationsCode
+ }
+ res.status(200).json(GQLCode)
}
-);
+)
/* ROUTE TO GET USER MONGO DB AND CONVERT TO GRAPHQL SERVER, CLIENT QUERIES AND MUTATIONS CODE */
router.post(
@@ -72,10 +79,10 @@ router.post(
MongoSchema: res.locals.MongoSchema,
GQLServerCode: res.locals.GQLServerCode,
GQLClientQueriesCode: res.locals.GQLClientQueriesCode,
- GQLClientMutationsCode: res.locals.GQLClientMutationsCode,
- };
- res.status(200).json(GQLCode);
+ GQLClientMutationsCode: res.locals.GQLClientMutationsCode
+ }
+ res.status(200).json(GQLCode)
}
-);
+)
-module.exports = router;
+module.exports = router
diff --git a/server/sampleDB.js b/server/sampleDB.js
index 0da326b..81a5eeb 100644
--- a/server/sampleDB.js
+++ b/server/sampleDB.js
@@ -1,11 +1,11 @@
export const SampleGQLServerCode =
- "const graphql = require('graphql');\nconst pool = require('../db/zopukfce/sql_pool.js');\n\nconst { \n GraphQLObjectType,\n GraphQLSchema,\n GraphQLID,\n GraphQLString, \n GraphQLInt, \n GraphQLBoolean,\n GraphQLList,\n GraphQLNonNull\n} = graphql;\n \nconst regionsType = new GraphQLObjectType({\n name: 'regions',\n fields: () => ({\n region_id: { type: GraphQLInt },\n region_name: { type: GraphQLString }\n })\n});\n\nconst countriesType = new GraphQLObjectType({\n name: 'countries',\n fields: () => ({\n region_id: { type: GraphQLInt },\n country_name: { type: GraphQLString },\n country_id: { type: GraphQLString }\n })\n});\n\nconst locationsType = new GraphQLObjectType({\n name: 'locations',\n fields: () => ({\n location_id: { type: GraphQLInt },\n country_id: { type: GraphQLString },\n state_province: { type: GraphQLString },\n city: { type: GraphQLString },\n postal_code: { type: GraphQLString },\n street_address: { type: GraphQLString }\n })\n});\n\nconst departmentsType = new GraphQLObjectType({\n name: 'departments',\n fields: () => ({\n location_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n department_name: { type: GraphQLString }\n })\n});\n\nconst jobsType = new GraphQLObjectType({\n name: 'jobs',\n fields: () => ({\n max_salary: { type: GraphQLString },\n job_title: { type: GraphQLString },\n min_salary: { type: GraphQLString },\n job_id: { type: GraphQLInt }\n })\n});\n\nconst employeesType = new GraphQLObjectType({\n name: 'employees',\n fields: () => ({\n email: { type: GraphQLString },\n hire_date: { type: GraphQLString },\n job_id: { type: GraphQLInt },\n salary: { type: GraphQLString },\n employee_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n manager_id: { type: GraphQLInt },\n first_name: { type: GraphQLString },\n last_name: { type: GraphQLString },\n phone_number: { type: GraphQLString }\n })\n});\n\nconst dependentsType = new GraphQLObjectType({\n name: 'dependents',\n fields: () => ({\n first_name: { type: GraphQLString },\n dependent_id: { type: GraphQLInt },\n relationship: { type: GraphQLString },\n last_name: { type: GraphQLString },\n employee_id: { type: GraphQLInt }\n })\n});\n\nconst RootQuery = new GraphQLObjectType({\n name: 'RootQueryType',\n fields: {\n everyRegions: {\n type: new GraphQLList(regionsType),\n resolve() {\n const sql = `SELECT * FROM \"regions\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n regions: {\n type: regionsType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"regions\" WHERE region_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyCountries: {\n type: new GraphQLList(countriesType),\n resolve() {\n const sql = `SELECT * FROM \"countries\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n countries: {\n type: countriesType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"countries\" WHERE region_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyLocations: {\n type: new GraphQLList(locationsType),\n resolve() {\n const sql = `SELECT * FROM \"locations\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n locations: {\n type: locationsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"locations\" WHERE location_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyDepartments: {\n type: new GraphQLList(departmentsType),\n resolve() {\n const sql = `SELECT * FROM \"departments\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n departments: {\n type: departmentsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"departments\" WHERE location_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyJobs: {\n type: new GraphQLList(jobsType),\n resolve() {\n const sql = `SELECT * FROM \"jobs\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n jobs: {\n type: jobsType,\n args: { max_salary: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"jobs\" WHERE max_salary = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyEmployees: {\n type: new GraphQLList(employeesType),\n resolve() {\n const sql = `SELECT * FROM \"employees\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n employees: {\n type: employeesType,\n args: { email: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"employees\" WHERE email = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyDependents: {\n type: new GraphQLList(dependentsType),\n resolve() {\n const sql = `SELECT * FROM \"dependents\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n dependents: {\n type: dependentsType,\n args: { first_name: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"dependents\" WHERE first_name = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n }\n }\n});\n\nconst Mutation = new GraphQLObjectType({\n name: 'Mutation',\n fields: {\n addregions: {\n type: regionsType,\n args: {\n region_id: { type: GraphQLInt },\n region_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"regions\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updateregions: {\n type: regionsType,\n args: {\n region_id: { type: GraphQLInt },\n region_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"regions\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deleteregions: {\n type: regionsType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"regions\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addcountries: {\n type: countriesType,\n args: {\n region_id: { type: GraphQLInt },\n country_name: { type: GraphQLString },\n country_id: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"countries\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatecountries: {\n type: countriesType,\n args: {\n region_id: { type: GraphQLInt },\n country_name: { type: GraphQLString },\n country_id: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"countries\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletecountries: {\n type: countriesType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"countries\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addlocations: {\n type: locationsType,\n args: {\n location_id: { type: GraphQLInt },\n country_id: { type: GraphQLString },\n state_province: { type: GraphQLString },\n city: { type: GraphQLString },\n postal_code: { type: GraphQLString },\n street_address: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"locations\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatelocations: {\n type: locationsType,\n args: {\n location_id: { type: GraphQLInt },\n country_id: { type: GraphQLString },\n state_province: { type: GraphQLString },\n city: { type: GraphQLString },\n postal_code: { type: GraphQLString },\n street_address: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"locations\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletelocations: {\n type: locationsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"locations\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n adddepartments: {\n type: departmentsType,\n args: {\n location_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n department_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"departments\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatedepartments: {\n type: departmentsType,\n args: {\n location_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n department_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"departments\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletedepartments: {\n type: departmentsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"departments\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addjobs: {\n type: jobsType,\n args: {\n max_salary: { type: GraphQLString },\n job_title: { type: GraphQLString },\n min_salary: { type: GraphQLString },\n job_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"jobs\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatejobs: {\n type: jobsType,\n args: {\n max_salary: { type: GraphQLString },\n job_title: { type: GraphQLString },\n min_salary: { type: GraphQLString },\n job_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"jobs\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletejobs: {\n type: jobsType,\n args: { max_salary: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"jobs\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addemployees: {\n type: employeesType,\n args: {\n email: { type: GraphQLString },\n hire_date: { type: GraphQLString },\n job_id: { type: GraphQLInt },\n salary: { type: GraphQLString },\n employee_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n manager_id: { type: GraphQLInt },\n first_name: { type: GraphQLString },\n last_name: { type: GraphQLString },\n phone_number: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"employees\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updateemployees: {\n type: employeesType,\n args: {\n email: { type: GraphQLString },\n hire_date: { type: GraphQLString },\n job_id: { type: GraphQLInt },\n salary: { type: GraphQLString },\n employee_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n manager_id: { type: GraphQLInt },\n first_name: { type: GraphQLString },\n last_name: { type: GraphQLString },\n phone_number: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"employees\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deleteemployees: {\n type: employeesType,\n args: { email: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"employees\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n adddependents: {\n type: dependentsType,\n args: {\n first_name: { type: GraphQLString },\n dependent_id: { type: GraphQLInt },\n relationship: { type: GraphQLString },\n last_name: { type: GraphQLString },\n employee_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"dependents\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatedependents: {\n type: dependentsType,\n args: {\n first_name: { type: GraphQLString },\n dependent_id: { type: GraphQLInt },\n relationship: { type: GraphQLString },\n last_name: { type: GraphQLString },\n employee_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"dependents\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletedependents: {\n type: dependentsType,\n args: { first_name: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"dependents\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n }\n }\n});\n\nmodule.exports = new GraphQLSchema({\n query: RootQuery,\n mutation: Mutation\n});";
+ "const graphql = require('graphql');\nconst pool = require('../db/zopukfce/sql_pool.js');\n\nconst { \n GraphQLObjectType,\n GraphQLSchema,\n GraphQLID,\n GraphQLString, \n GraphQLInt, \n GraphQLBoolean,\n GraphQLList,\n GraphQLNonNull\n} = graphql;\n \nconst regionsType = new GraphQLObjectType({\n name: 'regions',\n fields: () => ({\n region_id: { type: GraphQLInt },\n region_name: { type: GraphQLString }\n })\n});\n\nconst countriesType = new GraphQLObjectType({\n name: 'countries',\n fields: () => ({\n region_id: { type: GraphQLInt },\n country_name: { type: GraphQLString },\n country_id: { type: GraphQLString }\n })\n});\n\nconst locationsType = new GraphQLObjectType({\n name: 'locations',\n fields: () => ({\n location_id: { type: GraphQLInt },\n country_id: { type: GraphQLString },\n state_province: { type: GraphQLString },\n city: { type: GraphQLString },\n postal_code: { type: GraphQLString },\n street_address: { type: GraphQLString }\n })\n});\n\nconst departmentsType = new GraphQLObjectType({\n name: 'departments',\n fields: () => ({\n location_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n department_name: { type: GraphQLString }\n })\n});\n\nconst jobsType = new GraphQLObjectType({\n name: 'jobs',\n fields: () => ({\n max_salary: { type: GraphQLString },\n job_title: { type: GraphQLString },\n min_salary: { type: GraphQLString },\n job_id: { type: GraphQLInt }\n })\n});\n\nconst employeesType = new GraphQLObjectType({\n name: 'employees',\n fields: () => ({\n email: { type: GraphQLString },\n hire_date: { type: GraphQLString },\n job_id: { type: GraphQLInt },\n salary: { type: GraphQLString },\n employee_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n manager_id: { type: GraphQLInt },\n first_name: { type: GraphQLString },\n last_name: { type: GraphQLString },\n phone_number: { type: GraphQLString }\n })\n});\n\nconst dependentsType = new GraphQLObjectType({\n name: 'dependents',\n fields: () => ({\n first_name: { type: GraphQLString },\n dependent_id: { type: GraphQLInt },\n relationship: { type: GraphQLString },\n last_name: { type: GraphQLString },\n employee_id: { type: GraphQLInt }\n })\n});\n\nconst RootQuery = new GraphQLObjectType({\n name: 'RootQueryType',\n fields: {\n everyRegions: {\n type: new GraphQLList(regionsType),\n resolve() {\n const sql = `SELECT * FROM \"regions\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n regions: {\n type: regionsType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"regions\" WHERE region_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyCountries: {\n type: new GraphQLList(countriesType),\n resolve() {\n const sql = `SELECT * FROM \"countries\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n countries: {\n type: countriesType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"countries\" WHERE region_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyLocations: {\n type: new GraphQLList(locationsType),\n resolve() {\n const sql = `SELECT * FROM \"locations\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n locations: {\n type: locationsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"locations\" WHERE location_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyDepartments: {\n type: new GraphQLList(departmentsType),\n resolve() {\n const sql = `SELECT * FROM \"departments\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n departments: {\n type: departmentsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"departments\" WHERE location_id = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyJobs: {\n type: new GraphQLList(jobsType),\n resolve() {\n const sql = `SELECT * FROM \"jobs\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n jobs: {\n type: jobsType,\n args: { max_salary: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"jobs\" WHERE max_salary = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyEmployees: {\n type: new GraphQLList(employeesType),\n resolve() {\n const sql = `SELECT * FROM \"employees\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n employees: {\n type: employeesType,\n args: { email: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"employees\" WHERE email = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n },\n everyDependents: {\n type: new GraphQLList(dependentsType),\n resolve() {\n const sql = `SELECT * FROM \"dependents\";`\n return pool.query(sql)\n .then(res => res.rows)\n .catch(err => console.log('Error: ', err))\n }\n },\n dependents: {\n type: dependentsType,\n args: { first_name: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `SELECT * FROM \"dependents\" WHERE first_name = '${args.id}';`;\n return pool.query(sql)\n .then(res => res.rows[0])\n .catch(err => console.log('Error: ', err))\n }\n }\n }\n});\n\nconst Mutation = new GraphQLObjectType({\n name: 'Mutation',\n fields: {\n addregions: {\n type: regionsType,\n args: {\n region_id: { type: GraphQLInt },\n region_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"regions\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updateregions: {\n type: regionsType,\n args: {\n region_id: { type: GraphQLInt },\n region_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"regions\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deleteregions: {\n type: regionsType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"regions\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addcountries: {\n type: countriesType,\n args: {\n region_id: { type: GraphQLInt },\n country_name: { type: GraphQLString },\n country_id: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"countries\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatecountries: {\n type: countriesType,\n args: {\n region_id: { type: GraphQLInt },\n country_name: { type: GraphQLString },\n country_id: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"countries\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletecountries: {\n type: countriesType,\n args: { region_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"countries\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addlocations: {\n type: locationsType,\n args: {\n location_id: { type: GraphQLInt },\n country_id: { type: GraphQLString },\n state_province: { type: GraphQLString },\n city: { type: GraphQLString },\n postal_code: { type: GraphQLString },\n street_address: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"locations\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatelocations: {\n type: locationsType,\n args: {\n location_id: { type: GraphQLInt },\n country_id: { type: GraphQLString },\n state_province: { type: GraphQLString },\n city: { type: GraphQLString },\n postal_code: { type: GraphQLString },\n street_address: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"locations\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletelocations: {\n type: locationsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"locations\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n adddepartments: {\n type: departmentsType,\n args: {\n location_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n department_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"departments\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatedepartments: {\n type: departmentsType,\n args: {\n location_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n department_name: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"departments\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletedepartments: {\n type: departmentsType,\n args: { location_id: { type: GraphQLInt}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"departments\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addjobs: {\n type: jobsType,\n args: {\n max_salary: { type: GraphQLString },\n job_title: { type: GraphQLString },\n min_salary: { type: GraphQLString },\n job_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"jobs\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatejobs: {\n type: jobsType,\n args: {\n max_salary: { type: GraphQLString },\n job_title: { type: GraphQLString },\n min_salary: { type: GraphQLString },\n job_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"jobs\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletejobs: {\n type: jobsType,\n args: { max_salary: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"jobs\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n addemployees: {\n type: employeesType,\n args: {\n email: { type: GraphQLString },\n hire_date: { type: GraphQLString },\n job_id: { type: GraphQLInt },\n salary: { type: GraphQLString },\n employee_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n manager_id: { type: GraphQLInt },\n first_name: { type: GraphQLString },\n last_name: { type: GraphQLString },\n phone_number: { type: GraphQLString }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"employees\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updateemployees: {\n type: employeesType,\n args: {\n email: { type: GraphQLString },\n hire_date: { type: GraphQLString },\n job_id: { type: GraphQLInt },\n salary: { type: GraphQLString },\n employee_id: { type: GraphQLInt },\n department_id: { type: GraphQLInt },\n manager_id: { type: GraphQLInt },\n first_name: { type: GraphQLString },\n last_name: { type: GraphQLString },\n phone_number: { type: GraphQLString }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"employees\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deleteemployees: {\n type: employeesType,\n args: { email: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"employees\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n adddependents: {\n type: dependentsType,\n args: {\n first_name: { type: GraphQLString },\n dependent_id: { type: GraphQLInt },\n relationship: { type: GraphQLString },\n last_name: { type: GraphQLString },\n employee_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n const columns = Object.keys(args).map(el => `\"${el}\"`);\n const values = Object.values(args).map(el => `'${el}'`);\n const sql = `INSERT INTO \"dependents\" (${columns}) VALUES (${values}) RETURNING *`;\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n updatedependents: {\n type: dependentsType,\n args: {\n first_name: { type: GraphQLString },\n dependent_id: { type: GraphQLInt },\n relationship: { type: GraphQLString },\n last_name: { type: GraphQLString },\n employee_id: { type: GraphQLInt }\n },\n resolve(parent, args) {\n let updateValues = '';\n for (const prop in args) {\n if (updateValues.length > 0) updateValues += `, `;\n updateValues += `\"${prop}\" = '${args[prop]}' `;\n }\n const sql = `UPDATE \"dependents\" SET ${updateValues} WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n },\n deletedependents: {\n type: dependentsType,\n args: { first_name: { type: GraphQLString}},\n resolve(parent, args) {\n const sql = `DELETE FROM \"dependents\" WHERE id = '${args.id}' RETURNING *;`\n return pool.connect()\n .then(client => {\n return client.query(sql)\n .then(res => {\n client.release();\n return res.rows[0];\n })\n .catch(err => {\n client.release();\n console.log('Error: ', err);\n })\n })\n }\n }\n }\n});\n\nmodule.exports = new GraphQLSchema({\n query: RootQuery,\n mutation: Mutation\n});"
export const SampleGQLClientQueriesCode =
- "import { gql } from 'apollo-boost';\n\nconst queryEveryregions = gql`\n {\n everyRegions {\n region_id\n region_name\n }\n }\n`\n\nconst queryregionsById = gql`\n query($region_id: Number!) {\n regions(region_id: $region_id) {\n region_id\n region_name\n }\n }\n`\n\nconst queryEverycountries = gql`\n {\n everyCountries {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst querycountriesById = gql`\n query($region_id: Number!) {\n countries(region_id: $region_id) {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst queryEverylocations = gql`\n {\n everyLocations {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst querylocationsById = gql`\n query($location_id: Number!) {\n locations(location_id: $location_id) {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst queryEverydepartments = gql`\n {\n everyDepartments {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst querydepartmentsById = gql`\n query($location_id: Number!) {\n departments(location_id: $location_id) {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst queryEveryjobs = gql`\n {\n everyJobs {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst queryjobsById = gql`\n query($max_salary: numeric!) {\n jobs(max_salary: $max_salary) {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst queryEveryemployees = gql`\n {\n everyEmployees {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst queryemployeesById = gql`\n query($email: character varying!) {\n employees(email: $email) {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst queryEverydependents = gql`\n {\n everyDependents {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nconst querydependentsById = gql`\n query($first_name: character varying!) {\n dependents(first_name: $first_name) {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nexport { queryEveryregions, queryregionsById , queryEverycountries, querycountriesById , queryEverylocations, querylocationsById , queryEverydepartments, querydepartmentsById , queryEveryjobs, queryjobsById , queryEveryemployees, queryemployeesById , queryEverydependents, querydependentsById };";
+ "import { gql } from 'apollo-boost';\n\nconst queryEveryregions = gql`\n {\n everyRegions {\n region_id\n region_name\n }\n }\n`\n\nconst queryregionsById = gql`\n query($region_id: Number!) {\n regions(region_id: $region_id) {\n region_id\n region_name\n }\n }\n`\n\nconst queryEverycountries = gql`\n {\n everyCountries {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst querycountriesById = gql`\n query($region_id: Number!) {\n countries(region_id: $region_id) {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst queryEverylocations = gql`\n {\n everyLocations {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst querylocationsById = gql`\n query($location_id: Number!) {\n locations(location_id: $location_id) {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst queryEverydepartments = gql`\n {\n everyDepartments {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst querydepartmentsById = gql`\n query($location_id: Number!) {\n departments(location_id: $location_id) {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst queryEveryjobs = gql`\n {\n everyJobs {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst queryjobsById = gql`\n query($max_salary: numeric!) {\n jobs(max_salary: $max_salary) {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst queryEveryemployees = gql`\n {\n everyEmployees {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst queryemployeesById = gql`\n query($email: character varying!) {\n employees(email: $email) {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst queryEverydependents = gql`\n {\n everyDependents {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nconst querydependentsById = gql`\n query($first_name: character varying!) {\n dependents(first_name: $first_name) {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nexport { queryEveryregions, queryregionsById , queryEverycountries, querycountriesById , queryEverylocations, querylocationsById , queryEverydepartments, querydepartmentsById , queryEveryjobs, queryjobsById , queryEveryemployees, queryemployeesById , queryEverydependents, querydependentsById };"
export const SampleGQLClientMutationsCode =
- "import { gql } from 'apollo-boost';\n\nconst addregionsMutation = gql`\n mutation($region_name: character varying) {\n addregions(region_name: $region_name) {\n region_id\n region_name\n }\n }\n`\n\nconst updateregionsMutation = gql`\n mutation($region_id: Number!, $region_name: character varying) {\n updateregions(region_id: $region_id, region_name: $region_name) {\n region_id\n region_name\n }\n }\n`\n\nconst deleteregionsMutation = gql`\n mutation($region_id: Number!){\n deleteregions(region_id: $region_id){\n region_id\n region_name\n }\n }\n`\n\nconst addcountriesMutation = gql`\n mutation($country_name: character varying, $country_id: character) {\n addcountries(country_name: $country_name, country_id: $country_id) {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst updatecountriesMutation = gql`\n mutation($region_id: Number!, $country_name: character varying, $country_id: character) {\n updatecountries(region_id: $region_id, country_name: $country_name, country_id: $country_id) {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst deletecountriesMutation = gql`\n mutation($region_id: Number!){\n deletecountries(region_id: $region_id){\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst addlocationsMutation = gql`\n mutation($country_id: character, $state_province: character varying, $city: character varying, $postal_code: character varying, $street_address: character varying) {\n addlocations(country_id: $country_id, state_province: $state_province, city: $city, postal_code: $postal_code, street_address: $street_address) {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst updatelocationsMutation = gql`\n mutation($location_id: Number!, $country_id: character, $state_province: character varying, $city: character varying, $postal_code: character varying, $street_address: character varying) {\n updatelocations(location_id: $location_id, country_id: $country_id, state_province: $state_province, city: $city, postal_code: $postal_code, street_address: $street_address) {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst deletelocationsMutation = gql`\n mutation($location_id: Number!){\n deletelocations(location_id: $location_id){\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst adddepartmentsMutation = gql`\n mutation($department_id: Int, $department_name: character varying) {\n adddepartments(department_id: $department_id, department_name: $department_name) {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst updatedepartmentsMutation = gql`\n mutation($location_id: Number!, $department_id: Int, $department_name: character varying) {\n updatedepartments(location_id: $location_id, department_id: $department_id, department_name: $department_name) {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst deletedepartmentsMutation = gql`\n mutation($location_id: Number!){\n deletedepartments(location_id: $location_id){\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst addjobsMutation = gql`\n mutation($job_title: character varying, $min_salary: numeric, $job_id: Int) {\n addjobs(job_title: $job_title, min_salary: $min_salary, job_id: $job_id) {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst updatejobsMutation = gql`\n mutation($max_salary: numeric!, $job_title: character varying, $min_salary: numeric, $job_id: Int) {\n updatejobs(max_salary: $max_salary, job_title: $job_title, min_salary: $min_salary, job_id: $job_id) {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst deletejobsMutation = gql`\n mutation($max_salary: numeric!){\n deletejobs(max_salary: $max_salary){\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst addemployeesMutation = gql`\n mutation($hire_date: date, $job_id: Int, $salary: numeric, $employee_id: Int, $department_id: Int, $manager_id: Int, $first_name: character varying, $last_name: character varying, $phone_number: character varying) {\n addemployees(hire_date: $hire_date, job_id: $job_id, salary: $salary, employee_id: $employee_id, department_id: $department_id, manager_id: $manager_id, first_name: $first_name, last_name: $last_name, phone_number: $phone_number) {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst updateemployeesMutation = gql`\n mutation($email: character varying!, $hire_date: date, $job_id: Int, $salary: numeric, $employee_id: Int, $department_id: Int, $manager_id: Int, $first_name: character varying, $last_name: character varying, $phone_number: character varying) {\n updateemployees(email: $email, hire_date: $hire_date, job_id: $job_id, salary: $salary, employee_id: $employee_id, department_id: $department_id, manager_id: $manager_id, first_name: $first_name, last_name: $last_name, phone_number: $phone_number) {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst deleteemployeesMutation = gql`\n mutation($email: character varying!){\n deleteemployees(email: $email){\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst adddependentsMutation = gql`\n mutation($dependent_id: Int, $relationship: character varying, $last_name: character varying, $employee_id: Int) {\n adddependents(dependent_id: $dependent_id, relationship: $relationship, last_name: $last_name, employee_id: $employee_id) {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nconst updatedependentsMutation = gql`\n mutation($first_name: character varying!, $dependent_id: Int, $relationship: character varying, $last_name: character varying, $employee_id: Int) {\n updatedependents(first_name: $first_name, dependent_id: $dependent_id, relationship: $relationship, last_name: $last_name, employee_id: $employee_id) {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nconst deletedependentsMutation = gql`\n mutation($first_name: character varying!){\n deletedependents(first_name: $first_name){\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nexport {\n addregionsMutation,\n updateregionsMutation,\n deleteregionsMutation,\n addcountriesMutation,\n updatecountriesMutation,\n deletecountriesMutation,\n addlocationsMutation,\n updatelocationsMutation,\n deletelocationsMutation,\n adddepartmentsMutation,\n updatedepartmentsMutation,\n deletedepartmentsMutation,\n addjobsMutation,\n updatejobsMutation,\n deletejobsMutation,\n addemployeesMutation,\n updateemployeesMutation,\n deleteemployeesMutation,\n adddependentsMutation,\n updatedependentsMutation,\n deletedependentsMutation,\n};";
+ "import { gql } from 'apollo-boost';\n\nconst addregionsMutation = gql`\n mutation($region_name: character varying) {\n addregions(region_name: $region_name) {\n region_id\n region_name\n }\n }\n`\n\nconst updateregionsMutation = gql`\n mutation($region_id: Number!, $region_name: character varying) {\n updateregions(region_id: $region_id, region_name: $region_name) {\n region_id\n region_name\n }\n }\n`\n\nconst deleteregionsMutation = gql`\n mutation($region_id: Number!){\n deleteregions(region_id: $region_id){\n region_id\n region_name\n }\n }\n`\n\nconst addcountriesMutation = gql`\n mutation($country_name: character varying, $country_id: character) {\n addcountries(country_name: $country_name, country_id: $country_id) {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst updatecountriesMutation = gql`\n mutation($region_id: Number!, $country_name: character varying, $country_id: character) {\n updatecountries(region_id: $region_id, country_name: $country_name, country_id: $country_id) {\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst deletecountriesMutation = gql`\n mutation($region_id: Number!){\n deletecountries(region_id: $region_id){\n region_id\n country_name\n country_id\n }\n }\n`\n\nconst addlocationsMutation = gql`\n mutation($country_id: character, $state_province: character varying, $city: character varying, $postal_code: character varying, $street_address: character varying) {\n addlocations(country_id: $country_id, state_province: $state_province, city: $city, postal_code: $postal_code, street_address: $street_address) {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst updatelocationsMutation = gql`\n mutation($location_id: Number!, $country_id: character, $state_province: character varying, $city: character varying, $postal_code: character varying, $street_address: character varying) {\n updatelocations(location_id: $location_id, country_id: $country_id, state_province: $state_province, city: $city, postal_code: $postal_code, street_address: $street_address) {\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst deletelocationsMutation = gql`\n mutation($location_id: Number!){\n deletelocations(location_id: $location_id){\n location_id\n country_id\n state_province\n city\n postal_code\n street_address\n }\n }\n`\n\nconst adddepartmentsMutation = gql`\n mutation($department_id: Int, $department_name: character varying) {\n adddepartments(department_id: $department_id, department_name: $department_name) {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst updatedepartmentsMutation = gql`\n mutation($location_id: Number!, $department_id: Int, $department_name: character varying) {\n updatedepartments(location_id: $location_id, department_id: $department_id, department_name: $department_name) {\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst deletedepartmentsMutation = gql`\n mutation($location_id: Number!){\n deletedepartments(location_id: $location_id){\n location_id\n department_id\n department_name\n }\n }\n`\n\nconst addjobsMutation = gql`\n mutation($job_title: character varying, $min_salary: numeric, $job_id: Int) {\n addjobs(job_title: $job_title, min_salary: $min_salary, job_id: $job_id) {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst updatejobsMutation = gql`\n mutation($max_salary: numeric!, $job_title: character varying, $min_salary: numeric, $job_id: Int) {\n updatejobs(max_salary: $max_salary, job_title: $job_title, min_salary: $min_salary, job_id: $job_id) {\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst deletejobsMutation = gql`\n mutation($max_salary: numeric!){\n deletejobs(max_salary: $max_salary){\n max_salary\n job_title\n min_salary\n job_id\n }\n }\n`\n\nconst addemployeesMutation = gql`\n mutation($hire_date: date, $job_id: Int, $salary: numeric, $employee_id: Int, $department_id: Int, $manager_id: Int, $first_name: character varying, $last_name: character varying, $phone_number: character varying) {\n addemployees(hire_date: $hire_date, job_id: $job_id, salary: $salary, employee_id: $employee_id, department_id: $department_id, manager_id: $manager_id, first_name: $first_name, last_name: $last_name, phone_number: $phone_number) {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst updateemployeesMutation = gql`\n mutation($email: character varying!, $hire_date: date, $job_id: Int, $salary: numeric, $employee_id: Int, $department_id: Int, $manager_id: Int, $first_name: character varying, $last_name: character varying, $phone_number: character varying) {\n updateemployees(email: $email, hire_date: $hire_date, job_id: $job_id, salary: $salary, employee_id: $employee_id, department_id: $department_id, manager_id: $manager_id, first_name: $first_name, last_name: $last_name, phone_number: $phone_number) {\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst deleteemployeesMutation = gql`\n mutation($email: character varying!){\n deleteemployees(email: $email){\n email\n hire_date\n job_id\n salary\n employee_id\n department_id\n manager_id\n first_name\n last_name\n phone_number\n }\n }\n`\n\nconst adddependentsMutation = gql`\n mutation($dependent_id: Int, $relationship: character varying, $last_name: character varying, $employee_id: Int) {\n adddependents(dependent_id: $dependent_id, relationship: $relationship, last_name: $last_name, employee_id: $employee_id) {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nconst updatedependentsMutation = gql`\n mutation($first_name: character varying!, $dependent_id: Int, $relationship: character varying, $last_name: character varying, $employee_id: Int) {\n updatedependents(first_name: $first_name, dependent_id: $dependent_id, relationship: $relationship, last_name: $last_name, employee_id: $employee_id) {\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nconst deletedependentsMutation = gql`\n mutation($first_name: character varying!){\n deletedependents(first_name: $first_name){\n first_name\n dependent_id\n relationship\n last_name\n employee_id\n }\n }\n`\n\nexport {\n addregionsMutation,\n updateregionsMutation,\n deleteregionsMutation,\n addcountriesMutation,\n updatecountriesMutation,\n deletecountriesMutation,\n addlocationsMutation,\n updatelocationsMutation,\n deletelocationsMutation,\n adddepartmentsMutation,\n updatedepartmentsMutation,\n deletedepartmentsMutation,\n addjobsMutation,\n updatejobsMutation,\n deletejobsMutation,\n addemployeesMutation,\n updateemployeesMutation,\n deleteemployeesMutation,\n adddependentsMutation,\n updatedependentsMutation,\n deletedependentsMutation,\n};"
export const SQLSchema = {
name: 'Sample Database',
@@ -14,260 +14,260 @@ export const SQLSchema = {
primaryKey: 'region_id',
foreignKeys: null,
referencedBy: {
- countries: 'region_id',
+ countries: 'region_id'
},
columns: {
region_id: {
dataType: 'integer',
columnDefault: "nextval('regions_region_id_seq'::regclass)",
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
region_name: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 25,
- isNullable: 'YES',
- },
- },
+ isNullable: 'YES'
+ }
+ }
},
countries: {
primaryKey: 'country_id',
foreignKeys: {
region_id: {
referenceTable: 'regions',
- referenceKey: 'region_id',
- },
+ referenceKey: 'region_id'
+ }
},
referencedBy: {
- locations: 'country_id',
+ locations: 'country_id'
},
columns: {
region_id: {
dataType: 'integer',
columnDefault: null,
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
country_name: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 40,
- isNullable: 'YES',
+ isNullable: 'YES'
},
country_id: {
dataType: 'character',
columnDefault: null,
charMaxLength: 2,
- isNullable: 'NO',
- },
- },
+ isNullable: 'NO'
+ }
+ }
},
locations: {
primaryKey: 'location_id',
foreignKeys: {
country_id: {
referenceTable: 'countries',
- referenceKey: 'country_id',
- },
+ referenceKey: 'country_id'
+ }
},
referencedBy: {
- departments: 'location_id',
+ departments: 'location_id'
},
columns: {
location_id: {
dataType: 'integer',
columnDefault: "nextval('locations_location_id_seq'::regclass)",
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
country_id: {
dataType: 'character',
columnDefault: null,
charMaxLength: 2,
- isNullable: 'NO',
+ isNullable: 'NO'
},
state_province: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 25,
- isNullable: 'YES',
+ isNullable: 'YES'
},
city: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 30,
- isNullable: 'NO',
+ isNullable: 'NO'
},
postal_code: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 12,
- isNullable: 'YES',
+ isNullable: 'YES'
},
street_address: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 40,
- isNullable: 'YES',
- },
- },
+ isNullable: 'YES'
+ }
+ }
},
departments: {
primaryKey: 'department_id',
foreignKeys: {
location_id: {
referenceTable: 'locations',
- referenceKey: 'location_id',
- },
+ referenceKey: 'location_id'
+ }
},
referencedBy: {
- employees: 'department_id',
+ employees: 'department_id'
},
columns: {
location_id: {
dataType: 'integer',
columnDefault: null,
charMaxLength: null,
- isNullable: 'YES',
+ isNullable: 'YES'
},
department_id: {
dataType: 'integer',
columnDefault: "nextval('departments_department_id_seq'::regclass)",
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
department_name: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 30,
- isNullable: 'NO',
- },
- },
+ isNullable: 'NO'
+ }
+ }
},
jobs: {
primaryKey: 'job_id',
foreignKeys: null,
referencedBy: {
- employees: 'job_id',
+ employees: 'job_id'
},
columns: {
max_salary: {
dataType: 'numeric',
columnDefault: null,
charMaxLength: null,
- isNullable: 'YES',
+ isNullable: 'YES'
},
job_title: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 35,
- isNullable: 'NO',
+ isNullable: 'NO'
},
min_salary: {
dataType: 'numeric',
columnDefault: null,
charMaxLength: null,
- isNullable: 'YES',
+ isNullable: 'YES'
},
job_id: {
dataType: 'integer',
columnDefault: "nextval('jobs_job_id_seq'::regclass)",
charMaxLength: null,
- isNullable: 'NO',
- },
- },
+ isNullable: 'NO'
+ }
+ }
},
employees: {
primaryKey: 'employee_id',
foreignKeys: {
job_id: {
referenceTable: 'jobs',
- referenceKey: 'job_id',
+ referenceKey: 'job_id'
},
department_id: {
referenceTable: 'departments',
- referenceKey: 'department_id',
+ referenceKey: 'department_id'
},
manager_id: {
referenceTable: 'employees',
- referenceKey: 'employee_id',
- },
+ referenceKey: 'employee_id'
+ }
},
referencedBy: {
employees: 'manager_id',
- dependents: 'employee_id',
+ dependents: 'employee_id'
},
columns: {
email: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 100,
- isNullable: 'NO',
+ isNullable: 'NO'
},
hire_date: {
dataType: 'date',
columnDefault: null,
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
job_id: {
dataType: 'integer',
columnDefault: null,
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
salary: {
dataType: 'numeric',
columnDefault: null,
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
employee_id: {
dataType: 'integer',
columnDefault: "nextval('employees_employee_id_seq'::regclass)",
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
department_id: {
dataType: 'integer',
columnDefault: null,
charMaxLength: null,
- isNullable: 'YES',
+ isNullable: 'YES'
},
manager_id: {
dataType: 'integer',
columnDefault: null,
charMaxLength: null,
- isNullable: 'YES',
+ isNullable: 'YES'
},
first_name: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 20,
- isNullable: 'YES',
+ isNullable: 'YES'
},
last_name: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 25,
- isNullable: 'NO',
+ isNullable: 'NO'
},
phone_number: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 20,
- isNullable: 'YES',
- },
- },
+ isNullable: 'YES'
+ }
+ }
},
dependents: {
primaryKey: 'dependent_id',
foreignKeys: {
employee_id: {
referenceTable: 'employees',
- referenceKey: 'employee_id',
- },
+ referenceKey: 'employee_id'
+ }
},
referencedBy: null,
columns: {
@@ -275,35 +275,35 @@ export const SQLSchema = {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 50,
- isNullable: 'NO',
+ isNullable: 'NO'
},
dependent_id: {
dataType: 'integer',
columnDefault: "nextval('dependents_dependent_id_seq'::regclass)",
charMaxLength: null,
- isNullable: 'NO',
+ isNullable: 'NO'
},
relationship: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 25,
- isNullable: 'NO',
+ isNullable: 'NO'
},
last_name: {
dataType: 'character varying',
columnDefault: null,
charMaxLength: 50,
- isNullable: 'NO',
+ isNullable: 'NO'
},
employee_id: {
dataType: 'integer',
columnDefault: null,
charMaxLength: null,
- isNullable: 'NO',
- },
- },
- },
- },
-};
+ isNullable: 'NO'
+ }
+ }
+ }
+ }
+}
// module.exports = { GQLServerCode, GQLClientQueriesCode, GQLClientMutationsCode };
diff --git a/server/secretKey.js b/server/secretKey.js
index 271d9da..82d494e 100644
--- a/server/secretKey.js
+++ b/server/secretKey.js
@@ -1,3 +1,3 @@
-const secretKey = 'TeamGQLevatedRules';
+const secretKey = 'TeamGQLevatedRules'
-module.exports = secretKey;
+module.exports = secretKey
diff --git a/server/server.js b/server/server.js
index 5554a83..68aaa90 100644
--- a/server/server.js
+++ b/server/server.js
@@ -1,52 +1,52 @@
-const express = require('express');
-const router = require('./router');
-const cors = require('cors');
-const compression = require('compression');
+const express = require('express')
+const router = require('./router')
+const cors = require('cors')
+const compression = require('compression')
-const app = express();
-const PORT = 8080;
+const app = express()
+const PORT = 8080
/* CORS OPTIONS */
const corsOptions = {
origin: '*',
credentials: true, //access-control-allow-credentials:true
- optionSuccessStatus: 200,
-};
+ optionSuccessStatus: 200
+}
/* COMPRESSION FILTER */
const shouldCompress = (req, res) => {
if (req.headers['x-no-compression']) {
// don't compress responses with this request header
- return false;
+ return false
}
// fallback to standard filter function
- return compression.filter(req, res);
-};
+ return compression.filter(req, res)
+}
-app.use(cors(corsOptions));
-app.use(express.json());
-app.use(express.urlencoded({ extended: true }));
-app.use(compression({ filter: shouldCompress }));
+app.use(cors(corsOptions))
+app.use(express.json())
+app.use(express.urlencoded({ extended: true }))
+app.use(compression({ filter: shouldCompress }))
-app.use('/', router);
+app.use('/', router)
/* UNKNOWN ROUTE */
-app.use('*', (req, res) => res.status(404).send('This Page Does Not Exist'));
+app.use('*', (req, res) => res.status(404).send('This Page Does Not Exist'))
/* GLOBAL ERROR HANDLER */
app.use((err, req, res, next) => {
const defaultErr = {
log: 'Express error handler in unknown middleware error',
status: 500,
- message: { err: 'An error occurred' },
- };
- const errorObj = Object.assign({}, defaultErr, err);
- return res.status(errorObj.status).json(errorObj.message);
-});
+ message: { err: 'An error occurred' }
+ }
+ const errorObj = Object.assign({}, defaultErr, err)
+ return res.status(errorObj.status).json(errorObj.message)
+})
/* LISTEN */
app.listen(PORT, () => {
- console.log(`Server listening on PORT: ${PORT}...`);
-});
+ console.log(`Server listening on PORT: ${PORT}...`)
+})
-module.exports = app;
+module.exports = app
diff --git a/store.js b/store.js
index f186c8e..ec06a04 100644
--- a/store.js
+++ b/store.js
@@ -1,7 +1,6 @@
-import { configureStore } from '@reduxjs/toolkit';
-
-import demoReducer from './features/demoSlice';
+import { configureStore } from '@reduxjs/toolkit'
+import demoReducer from './features/demoSlice'
export const store = configureStore({
reducer: { demo: demoReducer },
-});
+})
diff --git a/tsconfig.json b/tsconfig.json
index 3dfd7dc..992d398 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,93 +1,12 @@
{
"compilerOptions": {
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
- /* Projects */
- // "incremental": true, /* Enable incremental compilation */
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
- // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
- /* Language and Environment */
- "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
- // "jsx": "preserve", /* Specify what JSX code is generated. */
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
- // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
- /* Modules */
- "module": "commonjs" /* Specify what module code is generated. */,
- // "rootDir": "./", /* Specify the root folder within your source files. */
- // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
- // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- // "resolveJsonModule": true, /* Enable importing .json files */
- // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */
- /* JavaScript Support */
- "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */, // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
- /* Emit */
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
- // "outDir": "./", /* Specify an output folder for all emitted files. */
- // "removeComments": true, /* Disable emitting comments. */
- // "noEmit": true, /* Disable emitting files from a compilation. */
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
- // "newLine": "crlf", /* Set the newline character for emitting files. */
- // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
- // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
- // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
- /* Interop Constraints */
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
- "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
- /* Type Checking */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
- // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
- // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
- // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
- // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
- /* Completeness */
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
- "skipLibCheck": true /* Skip type checking all .d.ts files. */,
+ "target": "es2016",
+ "module": "commonjs",
+ "allowJs": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "skipLibCheck": true,
"lib": ["dom", "dom.iterable", "esnext"],
"noEmit": true,
"incremental": true,
@@ -95,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
- "typeRoots": ["node_modules/@types"] // ADDED THIS BY HAND
+ "typeRoots": ["node_modules/@types"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]