Skip to content

Commit e2d054d

Browse files
committed
Added minimal and started advanced
1 parent 54b4e98 commit e2d054d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+24827
-105
lines changed

advanced/.babelrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"modules": false,
5+
"targets": {
6+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7+
}
8+
}],
9+
"stage-2"
10+
],
11+
"plugins": ["transform-vue-jsx", "transform-runtime"]
12+
}

advanced/.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

advanced/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.DS_Store
2+
node_modules/
3+
/dist/
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Editor directories and files
9+
.idea
10+
.vscode
11+
*.suo
12+
*.ntvs*
13+
*.njsproj
14+
*.sln

advanced/.install/index.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const fs = require('fs')
2+
const {
3+
replaceInFiles,
4+
deploy,
5+
writeEnv,
6+
getInfo,
7+
} = require('graphql-boilerplate-install')
8+
9+
module.exports = async ({ project, projectDir }) => {
10+
const templateName = 'graphql-boilerplate'
11+
12+
replaceInFiles(
13+
['server/src/index.js', 'server/package.json', 'server/database/prisma.yml'],
14+
templateName,
15+
project,
16+
)
17+
18+
console.log('Running $ prisma deploy...')
19+
20+
process.chdir('server/')
21+
22+
await deploy(false)
23+
const info = await getInfo()
24+
25+
process.chdir('../')
26+
27+
replaceInFiles(['server/src/index.js'], '__PRISMA_ENDPOINT__', info.httpEndpoint)
28+
29+
console.log(`\
30+
Next steps:
31+
1. Change directory: \`cd ${projectDir}/server\`
32+
2. Start local server: \`yarn start\` (you can now open a Playground at http://localhost:4000)
33+
3. Change directory: \`cd ..\`
34+
4. Start React app: \`yarn start\`
35+
5. Open browser: http://localhost:3000
36+
`)
37+
}

advanced/.install/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "install",
3+
"version": "0.0.0",
4+
"devDependencies": {
5+
"graphql-boilerplate-install": "0.1.8"
6+
}
7+
}

advanced/.install/yarn.lock

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
commander@^2.9.0:
6+
version "2.12.2"
7+
resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555"
8+
9+
[email protected], cross-spawn@^5.1.0:
10+
version "5.1.0"
11+
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
12+
dependencies:
13+
lru-cache "^4.0.1"
14+
shebang-command "^1.2.0"
15+
which "^1.2.9"
16+
17+
18+
version "0.1.8"
19+
resolved "https://registry.yarnpkg.com/graphql-boilerplate-install/-/graphql-boilerplate-install-0.1.8.tgz#7d71b3f5908d968aaa77c524765cc1b4d7bec348"
20+
dependencies:
21+
cross-spawn "5.1.0"
22+
npm-run "4.1.2"
23+
24+
isexe@^2.0.0:
25+
version "2.0.0"
26+
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
27+
28+
lru-cache@^4.0.1:
29+
version "4.1.1"
30+
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55"
31+
dependencies:
32+
pseudomap "^1.0.2"
33+
yallist "^2.1.2"
34+
35+
minimist@^1.2.0:
36+
version "1.2.0"
37+
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
38+
39+
npm-path@^2.0.2, npm-path@^2.0.3:
40+
version "2.0.4"
41+
resolved "https://registry.yarnpkg.com/npm-path/-/npm-path-2.0.4.tgz#c641347a5ff9d6a09e4d9bce5580c4f505278e64"
42+
dependencies:
43+
which "^1.2.10"
44+
45+
46+
version "4.1.2"
47+
resolved "https://registry.yarnpkg.com/npm-run/-/npm-run-4.1.2.tgz#1030e1ec56908c89fcc3fa366d03a2c2ba98eb99"
48+
dependencies:
49+
cross-spawn "^5.1.0"
50+
minimist "^1.2.0"
51+
npm-path "^2.0.3"
52+
npm-which "^3.0.1"
53+
serializerr "^1.0.3"
54+
sync-exec "^0.6.2"
55+
56+
npm-which@^3.0.1:
57+
version "3.0.1"
58+
resolved "https://registry.yarnpkg.com/npm-which/-/npm-which-3.0.1.tgz#9225f26ec3a285c209cae67c3b11a6b4ab7140aa"
59+
dependencies:
60+
commander "^2.9.0"
61+
npm-path "^2.0.2"
62+
which "^1.2.10"
63+
64+
protochain@^1.0.5:
65+
version "1.0.5"
66+
resolved "https://registry.yarnpkg.com/protochain/-/protochain-1.0.5.tgz#991c407e99de264aadf8f81504b5e7faf7bfa260"
67+
68+
pseudomap@^1.0.2:
69+
version "1.0.2"
70+
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
71+
72+
serializerr@^1.0.3:
73+
version "1.0.3"
74+
resolved "https://registry.yarnpkg.com/serializerr/-/serializerr-1.0.3.tgz#12d4c5aa1c3ffb8f6d1dc5f395aa9455569c3f91"
75+
dependencies:
76+
protochain "^1.0.5"
77+
78+
shebang-command@^1.2.0:
79+
version "1.2.0"
80+
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
81+
dependencies:
82+
shebang-regex "^1.0.0"
83+
84+
shebang-regex@^1.0.0:
85+
version "1.0.0"
86+
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
87+
88+
sync-exec@^0.6.2:
89+
version "0.6.2"
90+
resolved "https://registry.yarnpkg.com/sync-exec/-/sync-exec-0.6.2.tgz#717d22cc53f0ce1def5594362f3a89a2ebb91105"
91+
92+
which@^1.2.10, which@^1.2.9:
93+
version "1.3.0"
94+
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
95+
dependencies:
96+
isexe "^2.0.0"
97+
98+
yallist@^2.1.2:
99+
version "2.1.2"
100+
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"

advanced/.postcssrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
"postcss-import": {},
6+
"postcss-url": {},
7+
// to edit target browsers: use "browserslist" field in package.json
8+
"autoprefixer": {}
9+
}
10+
}

advanced/README.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<h1 align="center"><strong>Boilerplate for a Basic Fullstack GraphQL App with Vue</strong></h1>
2+
3+
<br />
4+
5+
![](https://imgur.com/ousyQaC.png)
6+
7+
<div align="center"><strong>🚀 Bootstrap your fullstack GraphQL app within seconds</strong></div>
8+
<div align="center">Basic starter kit for a fullstack GraphQL app with Vue and Node.js - based on best practices from the GraphQL community.</div>
9+
10+
## Features
11+
12+
- **Scalable GraphQL server:** The server uses [`graphql-yoga`](https://github.com/prisma/graphql-yoga) which is based on Apollo Server & Express
13+
- **Pre-configured Apollo Client:** The project comes with a preconfigured setup for Apollo Client
14+
- **GraphQL database:** Includes GraphQL database binding to [Prisma](https://www.prismagraphql.com) (running on MySQL)
15+
- **Tooling**: Out-of-the-box support for [GraphQL Playground](https://github.com/prisma/graphql-playground) & [query performance tracing](https://github.com/apollographql/apollo-tracing)
16+
- **Extensible**: Simple and flexible [data model](./database/datamodel.graphql) – easy to adjust and extend
17+
- **No configuration overhead**: Preconfigured [`graphql-config`](https://github.com/prisma/graphql-config) setup
18+
19+
20+
## Requirements
21+
22+
You need to have the [GraphQL CLI](https://github.com/graphql-cli/graphql-cli) installed to bootstrap your GraphQL server using `graphql create`:
23+
24+
```sh
25+
npm install -g graphql-cli
26+
```
27+
28+
## Getting started
29+
30+
```sh
31+
# 1. Bootstrap GraphQL server in directory `my-app`, based on `vue-fullstack-basic` boilerplate
32+
graphql create my-app --boilerplate vue-fullstack-basic
33+
34+
# 2. When prompted, deploy the Prisma service to a _public cluster_
35+
36+
# 3. Navigate into the `server` directory of the new project
37+
cd my-app/server
38+
39+
# 4. Start the server
40+
yarn dev # runs server on http://localhost:4000, and opens GraphQL PLayground
41+
42+
# 5. Open a new tab in the terminal and navigate back into my-app;
43+
# then run the app
44+
cd ..
45+
yarn start
46+
```
47+
48+
## Documentation
49+
50+
### Commands
51+
52+
* `yarn start` starts GraphQL server on `http://localhost:4000`
53+
* `yarn dev` starts GraphQL server on `http://localhost:4000` _and_ opens GraphQL Playground
54+
* `yarn playground` opens the GraphQL Playground for the `projects` from [`.graphqlconfig.yml`](./.graphqlconfig.yml)
55+
* `yarn prisma <subcommand>` gives access to local version of Prisma CLI (e.g. `yarn prisma deploy`)
56+
57+
> **Note**: We recommend that you're using `yarn dev` during development as it will give you access to the GraphQL API or your server (defined by the [application schema](./src/schema.graphql)) as well as to the Prisma API directly (defined by the [Prisma database schema](./generated/prisma.graphql)). If you're starting the server with `yarn start`, you'll only be able to access the API of the application schema.
58+
59+
### Server structure
60+
61+
![](https://imgur.com/95faUsa.png)
62+
63+
| File name               | Description         <br><br>|
64+
| :-- | :-- |
65+
| `├── .graphqlconfig.yml` | Configuration file based on [`graphql-config`](https://github.com/prisma/graphql-config) (e.g. used by GraphQL Playground).|
66+
| `└── database ` (_directory_) | _Contains all files that are related to the Prisma database service_ |\
67+
| `  ├── prisma.yml` | The root configuration file for your Prisma database service ([docs](https://www.prismagraphql.com/docs/reference/prisma.yml/overview-and-example-foatho8aip)) |
68+
| `  └── datamodel.graphql` | Defines your data model (written in [GraphQL SDL](https://blog.graph.cool/graphql-sdl-schema-definition-language-6755bcb9ce51)) |
69+
| `└── src ` (_directory_) | _Contains the source files for your GraphQL server_ |
70+
| `  ├── index.js` | The entry point for your GraphQL server |
71+
| `  ├── schema.graphql` | The **application schema** defining the API exposed to client applications |
72+
| `  └── generated` (_directory_) | _Contains generated files_ |
73+
| `    └── prisma.grapghql` | The **Prisma database schema** defining the Prisma GraphQL API |
74+
75+
## Contributing
76+
77+
The GraphQL boilerplates are maintained by the GraphQL community, with official support from the [Apollo](https://dev-blog.apollodata.com) & [Graphcool](https://blog.graph.cool/) teams.
78+
79+
Your feedback is **very helpful**, please share your opinion and thoughts! If you have any questions or want to contribute yourself, join the [`#graphql-boilerplate`](https://graphcool.slack.com/messages/graphql-boilerplate) channel on our [Slack](https://graphcool.slack.com/).

advanced/build/build.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict'
2+
require('./check-versions')()
3+
4+
process.env.NODE_ENV = 'production'
5+
6+
const ora = require('ora')
7+
const rm = require('rimraf')
8+
const path = require('path')
9+
const chalk = require('chalk')
10+
const webpack = require('webpack')
11+
const config = require('../config')
12+
const webpackConfig = require('./webpack.prod.conf')
13+
14+
const spinner = ora('building for production...')
15+
spinner.start()
16+
17+
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18+
if (err) throw err
19+
webpack(webpackConfig, (err, stats) => {
20+
spinner.stop()
21+
if (err) throw err
22+
process.stdout.write(stats.toString({
23+
colors: true,
24+
modules: false,
25+
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26+
chunks: false,
27+
chunkModules: false
28+
}) + '\n\n')
29+
30+
if (stats.hasErrors()) {
31+
console.log(chalk.red(' Build failed with errors.\n'))
32+
process.exit(1)
33+
}
34+
35+
console.log(chalk.cyan(' Build complete.\n'))
36+
console.log(chalk.yellow(
37+
' Tip: built files are meant to be served over an HTTP server.\n' +
38+
' Opening index.html over file:// won\'t work.\n'
39+
))
40+
})
41+
})

advanced/build/check-versions.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
'use strict'
2+
const chalk = require('chalk')
3+
const semver = require('semver')
4+
const packageConfig = require('../package.json')
5+
const shell = require('shelljs')
6+
7+
function exec (cmd) {
8+
return require('child_process').execSync(cmd).toString().trim()
9+
}
10+
11+
const versionRequirements = [
12+
{
13+
name: 'node',
14+
currentVersion: semver.clean(process.version),
15+
versionRequirement: packageConfig.engines.node
16+
}
17+
]
18+
19+
if (shell.which('npm')) {
20+
versionRequirements.push({
21+
name: 'npm',
22+
currentVersion: exec('npm --version'),
23+
versionRequirement: packageConfig.engines.npm
24+
})
25+
}
26+
27+
module.exports = function () {
28+
const warnings = []
29+
30+
for (let i = 0; i < versionRequirements.length; i++) {
31+
const mod = versionRequirements[i]
32+
33+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
34+
warnings.push(mod.name + ': ' +
35+
chalk.red(mod.currentVersion) + ' should be ' +
36+
chalk.green(mod.versionRequirement)
37+
)
38+
}
39+
}
40+
41+
if (warnings.length) {
42+
console.log('')
43+
console.log(chalk.yellow('To use this template, you must update following to modules:'))
44+
console.log()
45+
46+
for (let i = 0; i < warnings.length; i++) {
47+
const warning = warnings[i]
48+
console.log(' ' + warning)
49+
}
50+
51+
console.log()
52+
process.exit(1)
53+
}
54+
}

advanced/build/dev-client.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable */
2+
require('eventsource-polyfill')
3+
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4+
5+
hotClient.subscribe(function (event) {
6+
if (event.action === 'reload') {
7+
window.location.reload()
8+
}
9+
})

0 commit comments

Comments
 (0)