Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from gursesl/PR-apollo
Browse files Browse the repository at this point in the history
Pr apollo
  • Loading branch information
gursesl authored Nov 3, 2017
2 parents bd6640f + 6077361 commit 34f61c6
Show file tree
Hide file tree
Showing 39 changed files with 8,313 additions and 285 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"presets": ["env", "react", "stage-2"]
"presets": [
["env", {
"targets": {
"node": "current"
}
}], "react", "stage-2"]
}
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"root": true,
"extends": "airbnb",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ src/utils/db.json
package-lock.json

dist

# Webstorm files
.idea
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ Tech Todo
- [x] Solidify reducers
- [x] React router
- [x] Test react router
- [ ] Styled components
- [ ] Test styled components
- [ ] Apollo server
- [ ] Apollo mock server
- [ ] Test Apollo server
- [ ] Apollo client
- [ ] Test Apollo client
- [ ] Solidify central api calling script
- [x] Styled components
- [x] Test styled components
- [x] Add Proptypes
- [x] Test Proptypes
- [x] Refactor client/server scrips
Expand All @@ -51,13 +45,10 @@ Tech Todo

Functional Todo
==
- [ ] [Create a weather route/container/component](./docs/weather.md)
- [x] [Create a weather component](./docs/weather.md)
- [ ] [Create a login modal component](./docs/login.md)
- [ ] User sign-up
- [ ] Test user sign-up
- [ ] User sign-in
- [ ] Test user sign-in
- [ ] User sign-out
- [ ] Test user sign-out
- [ ] Sign-up with Google
- [ ] Test user sign-up
- [ ] Sign-up with Facebook
Expand Down
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
33 changes: 15 additions & 18 deletions buildScripts/build.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
/* eslint-disable no-console */
import webpack from 'webpack';
import chalk from 'chalk';
import webpackConfig from '../webpack.config.prod';
import webpack from 'webpack'
import chalk from 'chalk'
import webpackConfig from '../webpack.config.prod'

// process.env.NODE_ENV = 'production';
// process.env.NODE_ENV = 'production'

console.log(chalk.blue('Generating minified bundle for production. This will take a moment...'));
console.log(chalk.blue('Generating minified bundle for production. This will take a moment...'))

webpack(webpackConfig).run((err, stats) => {
if (err) { // fatal error, stop here
console.log(chalk.red(err));
return 1;
console.log(chalk.red(err))
return 1
}

const jsonStats = stats.toJson();
const jsonStats = stats.toJson()

if (jsonStats.hasErrors) {
return jsonStats.errors.map(error => console.log(chalk.red(error)));
return jsonStats.errors.map(error => console.log(chalk.red(error)))
}

if (jsonStats.hasWarnings) {
console.log(chalk.yellow('Webpack generated the following warnings:'));
jsonStats.warnings.map(warning => console.log(chalk.yellow(warning)));
console.log(chalk.yellow('Webpack generated the following warnings:'))
jsonStats.warnings.map(warning => console.log(chalk.yellow(warning)))
}

console.log(`Webpack stats: ${stats}`);

console.log(chalk.green('App has been built for production and written to /dist'));

return 0;
});
console.log(`Webpack stats: ${stats}`)
console.log(chalk.green('App has been built for production and written to /dist'))
return 0
})
3 changes: 3 additions & 0 deletions buildScripts/srcServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const port = 5000
const app = express()
const compiler = webpack(config)

// Serve static assets from /public
app.use(express.static('public'))

dotenv.config()
app.use(cors())

Expand Down
Binary file added docs/images/login-modal-mockup.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions docs/login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Login modal component

## Task list
- [x] Design login modal container/component - Semantic UI https://react.semantic-ui.com/modules/modal#modal-example-dimmer
![alt text](./images/login-modal-mockup.jpg "Login component mockup")
- [x] Apollo server
- [x] Apollo mock data server
- [x] Apollo client
- [ ] Refactor client/server folder structure
- [ ] Test Apollo server
- [ ] Test Apollo client
- [ ] Solidify central api calling script
- [ ] MongoDB
- [ ] Local setup
- [ ] mLabs setup, env key for Heroku
- [ ] Test login modal
- [ ] Login modal
- [ ] Test logout modal
- [ ] Logout modal
2 changes: 1 addition & 1 deletion docs/weather.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- [x] Component

## Plan of action
- [ ] Create first component similar to https://openweathermap.org/find?q=20165
- [x] Create first component similar to https://openweathermap.org/find?q=20165
- [x] Design container/component - https://mockflow.com/app/#Wireframe
![alt text](./images/weather-comp-mockup.jpg "Weather component mockup")
- [x] Create mock API
Expand Down
7 changes: 7 additions & 0 deletions gqlserver/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": [
"env",
"stage-0"
]
}

27 changes: 27 additions & 0 deletions gqlserver/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "gqlserver",
"version": "1.0.0",
"description": "GraphQL Server for Cherry Pie",
"main": "server.js",
"scripts": {
"start": "nodemon ./server.js --exec babel-node -e js",
"test": "jest"
},
"author": "Levent Gurses",
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"nodemon": "^1.12.1"
},
"dependencies": {
"apollo-server-express": "^1.1.7",
"body-parser": "^1.18.2",
"chalk": "^2.2.0",
"cors": "^2.8.4",
"express": "^4.16.2",
"graphql": "^0.11.7",
"graphql-tools": "^2.5.1"
}
}
17 changes: 17 additions & 0 deletions gqlserver/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import express from 'express'
import bodyParser from 'body-parser'
import cors from 'cors'
import chalk from 'chalk'
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express'
import { schema } from './src/schema'

const PORT = process.env.GRAPHQL_PORT || 4000
const server = express()
server.use('*', cors({ origin: '*' }))

server.use('/graphql', bodyParser.json(), graphqlExpress({ schema }))
server.use('/graphiql', bodyParser.json(), graphiqlExpress({ endpointURL: '/graphql' }))

server.listen(PORT, () => {
console.log(chalk.green(`GraphQL server is running on port ${PORT}`)) // eslint-disable-line no-console
})
66 changes: 66 additions & 0 deletions gqlserver/src/resolvers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
export const users = [
{
id: '1',
userName: 'weraa',
password: 'passw0rd',
email: 'wer@email.com',
firstName: 'Wera',
lastName: 'Andersen',
address: '123 Maple St.',
address2: 'Unit 320',
city: 'Maperville',
state: 'IL',
zip: '22902',
userType: 'caregiver',
},
{
id: '2',
userName: 'weraa2',
password: 'passw0rd',
email: 'weraa@email.com',
firstName: 'Smith',
lastName: 'Johnson',
address: '123 Maple St.',
address2: 'Unit 320',
city: 'Maperville',
state: 'IL',
zip: '22902',
userType: 'caregiver',
},
{
id: '3',
userName: 'angel23',
password: 'passw0rd',
email: 'weraa@email.com',
firstName: 'Angle',
lastName: 'Lamar',
address: '123 Maple St.',
address2: 'Unit 320',
city: 'Maperville',
state: 'IL',
zip: '22902',
userType: 'caregiver',
},
{
id: '4',
userName: 'wera44',
password: 'passw0rd',
email: 'weraa@email.com',
firstName: 'Wera',
lastName: 'Jeromski',
address: '123 Maple St.',
address2: 'Unit 320',
city: 'Maperville',
state: 'IL',
zip: '22902',
userType: 'caregiver',
},
]

const resolvers = {
Query: {
users: () => users,
},
}

export default resolvers
28 changes: 28 additions & 0 deletions gqlserver/src/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools'
import resolvers from './resolvers'

const typeDefs = `
type User {
id: ID!
userName: String!
password: String!
email: String!
firstName: String
lastName: String
address: String
address2: String
city: String
state: String
zip: String
userType: String!
}
type Query {
users: [User]
}
`

const schema = makeExecutableSchema({ typeDefs, resolvers })
// // addMockFunctionsToSchema({ schema })

export { schema, typeDefs }
11 changes: 11 additions & 0 deletions gqlserver/src/tests/resolvers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import resolvers, { users } from '../resolvers'

describe('Resolvers', () => {
it('should return data', () => {
expect(resolvers.Query.users().length).toBe(4)
})

it('should behave...', () => {
expect(users.length).toBe(4)
})
})
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'!webpack.*.js',
'!**/vendor.*',
'!src/index.js',
'!gqlserver/server.js',
],
testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)(spec|test).js?(x)'],
globals: {
Expand All @@ -32,4 +33,8 @@ module.exports = {
statements: 50,
},
},
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js',
},
}
Loading

0 comments on commit 34f61c6

Please sign in to comment.