Skip to content

Commit

Permalink
Setup server to client relation
Browse files Browse the repository at this point in the history
  • Loading branch information
elevenpassin committed Dec 20, 2017
1 parent 810e02e commit 2e543e7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const schema = makeExecutableSchema({

const app = express();

app.get('/ja', (req, res) => {
res.send('JA JA JA');
})

app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));

app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
Expand Down
3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
},
"proxy": "http://localhost:3001/"
}
4 changes: 4 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

fetch('/ja')
.then(resp=> resp.text())
.then(txt => console.log(txt));

class App extends Component {
render() {
return (
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "concurrently \"yarn run server\" \"yarn run client\"",
"server": "nodemon app.js",
"client": "node start-client.js"
},
"dependencies": {
"apollo-server-express": "^1.3.2",
"body-parser": "^1.18.2",
"express": "^4.16.2",
"graphql": "^0.12.3",
"graphql-tools": "^2.14.1",
"lodash": "^4.17.4"
},
"devDependencies": {
"concurrently": "^3.5.1"
}
}
7 changes: 7 additions & 0 deletions start-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* This serves as a utility to cd into the client directory and run the webpack development server.
* This is because in Windows CMD, you can't do something like "cd client && yarn start".
*/
const args = [ 'start' ];
const opts = { stdio: 'inherit', cwd: 'client', shell: true };
require('child_process').spawn('yarn', args, opts);

0 comments on commit 2e543e7

Please sign in to comment.