Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/hello-world/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"es2015",
"stage-2"
]
}
14 changes: 14 additions & 0 deletions examples/hello-world/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
34 changes: 32 additions & 2 deletions examples/hello-world/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
node_modules/
client/main.js
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules
/bower_components

# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log

# e2e
/e2e/*.js
/e2e/*.map

#System Files
.DS_Store
Thumbs.db
14 changes: 0 additions & 14 deletions examples/hello-world/.meteor/.finished-upgraders

This file was deleted.

2 changes: 0 additions & 2 deletions examples/hello-world/.meteor/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions examples/hello-world/.meteor/.id

This file was deleted.

21 changes: 0 additions & 21 deletions examples/hello-world/.meteor/packages

This file was deleted.

2 changes: 0 additions & 2 deletions examples/hello-world/.meteor/platforms

This file was deleted.

1 change: 0 additions & 1 deletion examples/hello-world/.meteor/release

This file was deleted.

72 changes: 0 additions & 72 deletions examples/hello-world/.meteor/versions

This file was deleted.

32 changes: 32 additions & 0 deletions examples/hello-world/angular-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"project": {
"version": "1.0.0-beta.11-webpack.8",
"name": "hello-world"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": "assets",
"index": "index.html",
"main": "main.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [],
"scripts": [],
"environments": {
"source": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"dev": "environments/environment.dev.ts"
}
}
],
"addons": [],
"packages": [],
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"lazyRoutePrefix": "+"
}
}
43 changes: 43 additions & 0 deletions examples/hello-world/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';

import { apolloExpress, graphiqlExpress } from 'apollo-server';
import { makeExecutableSchema } from 'graphql-tools';

import { schema, resolvers } from './schema';

const PORT = 4300;
const app = express();

//app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.use('/graphql', apolloExpress((req) => {
// Get the query, the same way express-graphql does it
// https://github.com/graphql/express-graphql/blob/3fa6e68582d6d933d37fa9e841da5d2aa39261cd/src/index.js#L257
const query = req.query.query || req.body.query;
if (query && query.length > 2000) {
// None of our app's queries are this long
// Probably indicates someone trying to send an overly expensive query
throw new Error('Query too large.');
}

return {
schema: executableSchema
};
}));

app.use('/graphiql', graphiqlExpress({
endpointURL: '/graphql',
}));

app.listen(PORT, () => console.log(
`API Server is now running on http://localhost:${PORT}`
));

const executableSchema = makeExecutableSchema({
typeDefs: schema,
resolvers,
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import casual from 'casual-browserify';
import casual from 'casual';

export const schema = [`
type Email {
Expand Down Expand Up @@ -52,12 +52,13 @@ export const resolvers = {
lastName: ({lastName}) => lastName || casual.user.lastName,
},
Mutation: {
addUser: (root, { firstName, lastName }) => {
addUser: (_, { firstName, lastName }) => {
const user = casual.user;

user.firstName = firstName;
user.lastName = lastName;

return user;
},
},
}
}
6 changes: 0 additions & 6 deletions examples/hello-world/client/index.html

This file was deleted.

10 changes: 0 additions & 10 deletions examples/hello-world/client/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions examples/hello-world/custom.d.ts

This file was deleted.

67 changes: 43 additions & 24 deletions examples/hello-world/package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
{
"name": "apollo-test-app",
"private": true,
"name": "hello-world",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "meteor run",
"dev": "rimraf node_modules/angular2-apollo && npm i && npm start"
"start": "concurrently \"npm run server\" \"npm run client\"",
"client": "ng serve --proxy-conf proxy.conf.json",
"server": "nodemon api/index.js --watch api --exec babel-node"
},
"private": true,
"dependencies": {
"@angular/common": "^2.0.0-rc.6",
"@angular/compiler": "^2.0.0-rc.6",
"@angular/core": "^2.0.0-rc.6",
"@angular/forms": "^2.0.0-rc.6",
"@angular/platform-browser": "^2.0.0-rc.6",
"@angular/platform-browser-dynamic": "^2.0.0-rc.6",
"angular2-apollo": "file:../../",
"apollo-client": "^0.4.13",
"casual-browserify": "^1.5.2",
"es6-shim": "^0.35.1",
"express": "^4.13.4",
"fs.extra": "^1.3.2",
"graphql": "^0.5.0",
"graphql-tag": "^0.1.9",
"graphql-tools": "^0.3.8",
"http-proxy-middleware": "^0.14.0",
"meteor-node-stubs": "~0.2.0",
"reflect-metadata": "^0.1.3",
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"angular2-apollo": "^0.4.4",
"apollo-client": "^0.4.14",
"core-js": "^2.4.0",
"rxjs": "5.0.0-beta.11",
"zone.js": "^0.6.12"
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.17"
},
"devDependencies": {
"rimraf": "^2.5.2"
"@angular/platform-server": "2.0.0-rc.5",
"@types/isomorphic-fetch": "0.0.30",
"@types/node": "^6.0.38",
"angular-cli": "1.0.0-beta.11-webpack.8",
"apollo-server": "^0.2.6",
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-2": "^6.13.0",
"babel-register": "^6.14.0",
"body-parser": "^1.15.2",
"casual": "^1.5.3",
"codelyzer": "~0.0.26",
"concurrently": "^2.2.0",
"cors": "^2.8.0",
"express": "^4.14.0",
"graphql": "^0.7.0",
"graphql-tools": "^0.6.5",
"nodemon": "^1.10.2",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.0"
}
}
10 changes: 10 additions & 0 deletions examples/hello-world/proxy.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"/graphql": {
"target": "http://localhost:4300",
"secure": false
},
"/graphiql": {
"target": "http://localhost:4300",
"secure": false
}
}
Loading