Skip to content

Commit ad4fb23

Browse files
committedMay 7, 2019
initial setup
1 parent 3fbe208 commit ad4fb23

17 files changed

+226
-84
lines changed
 

‎.circleci/config.yml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
7+
jobs:
8+
production:
9+
docker:
10+
- image: circleci/node:8.10.0
11+
environment:
12+
STAGE: production
13+
NOW_PROJECT: marvel-graphql
14+
NOW_ALIAS: https://api.marvelql.com
15+
working_directory: ~/repo
16+
steps:
17+
- checkout
18+
- restore_cache:
19+
keys:
20+
- v1-dependencies-13.1.2
21+
# fallback to using the latest cache if no exact match is found
22+
- v1-dependencies-
23+
- run: yarn install
24+
- save_cache:
25+
paths:
26+
- node_modules
27+
key: v1-dependencies-13.1.2
28+
- run: yarn deploy
29+
30+
staging:
31+
docker:
32+
- image: circleci/node:8.10.0
33+
environment:
34+
STAGE: staging
35+
NOW_PROJECT: marvel-graphql-staging
36+
NOW_ALIAS: https://staging.api.marvelql.com
37+
working_directory: ~/repo
38+
steps:
39+
- checkout
40+
- restore_cache:
41+
keys:
42+
- v1-dependencies-13.1.2
43+
- v1-dependencies-
44+
- run: yarn install
45+
- save_cache:
46+
paths:
47+
- node_modules
48+
key: v1-dependencies-13.1.2
49+
- run: yarn deploy
50+
51+
publish-apollo:
52+
docker:
53+
# specify the version you desire here
54+
- image: circleci/node:8.10.0
55+
working_directory: ~/repo
56+
steps:
57+
- checkout
58+
- run: yarn install
59+
# Start the GraphQL server. If a different command is used to
60+
# start the server, use it in place of `npm start` here.
61+
- run:
62+
name: Starting server
63+
command: yarn start
64+
background: true
65+
# make sure the server has enough time to start up before running
66+
# commands against it
67+
- run: sleep 5
68+
# When running on the 'master' branch, push the latest version
69+
# of the schema to Apollo Engine.
70+
- run: |
71+
yarn apollo service:push --tag="${CIRCLE_BRANCH}"
72+
73+
workflows:
74+
version: 2
75+
deploy-publish:
76+
jobs:
77+
- production:
78+
filters:
79+
branches:
80+
only:
81+
- master
82+
- staging:
83+
filters:
84+
branches:
85+
ignore:
86+
- master
87+
- publish-apollo

‎.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.next
2+
node_modules
3+
generated

‎.now/now.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": 2,
3+
"name": "server",
4+
"env": {},
5+
"builds": [
6+
{
7+
"src": "packages/server/dist/src/index.js",
8+
"use": "@now/node-server@canary"
9+
}
10+
],
11+
"routes": [
12+
{
13+
"src": "/(.*)",
14+
"dest": "packages/server/dist/src/index.js"
15+
}
16+
]
17+
}

‎.now/now.production.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": 2,
3+
"name": "prod",
4+
"env": {},
5+
"builds": [
6+
{
7+
"src": "packages/server/dist/src/index.js",
8+
"use": "@now/node-server@canary"
9+
}
10+
],
11+
"routes": [
12+
{
13+
"src": "/(.*)",
14+
"dest": "packages/server/dist/src/index.js"
15+
}
16+
]
17+
}

‎.now/now.staging.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": 2,
3+
"name": "staging",
4+
"env": {},
5+
"builds": [
6+
{
7+
"src": "packages/server/dist/src/index.js",
8+
"use": "@now/node-server@canary"
9+
}
10+
],
11+
"routes": [
12+
{
13+
"src": "/(.*)",
14+
"dest": "packages/server/dist/src/index.js"
15+
}
16+
]
17+
}

‎.nowignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.next
2+
node_modules

‎.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"bracketSpacing": true,
4+
"semi": true,
5+
"trailingComma": "all"
6+
}

‎.scripts/deploy-now.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# ENV Variables, Note: ACCESS_TOKEN and NOW_TOKEN in gitlab-ci
6+
ORIGIN='*'
7+
# NOW config
8+
TEAM=$NOW_TEAM
9+
PROJECT=$NOW_PROJECT
10+
ALIAS=$NOW_ALIAS
11+
12+
export PATH="./node_modules/.bin:$PATH"
13+
# 1. Wait for deployment ready
14+
now --target production -A now.$STAGE.json -e STAGE=$STAGE -e ENGINE_TAG=${CIRCLE_BRANCH:-staging} --token "$NOW_TOKEN" --scope $TEAM
15+
# URL=$(now --target $STAGE -e STAGE=$STAGE -e ENGINE_TAG=${CIRCLE_BRANCH:-staging} --token "$NOW_TOKEN" --scope $TEAM)
16+
# 2. Alias
17+
# now alias set "$URL" "$ALIAS" --token "$NOW_TOKEN" --scope $TEAM
18+
# 3. Purge old services
19+
now remove $PROJECT --yes --safe --token "$NOW_TOKEN" --scope $TEAM || true
20+
21+
# 5. Log results
22+
now ls $PROJECT --token "$NOW_TOKEN" --scope $TEAM || true

‎.scripts/deploy.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# bash ./.scripts/generateEnvFile.sh
2+
bash ./.scripts/deploy-now.sh

‎.scripts/generateEnvFile.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
for var in $(printenv); do
3+
if [[ $var == PRISMA_* ]] ;
4+
then
5+
echo "$var" >> .env
6+
fi
7+
done

‎netlify.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build]
2+
command = "yarn site build"
3+
publish = "./oss/public"
4+
5+
[build.environment]
6+
NODE_VERSION = "v11.14.0"
7+
YARN_VERSION = "1.15.2"

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
]
2222
},
2323
"devDependencies": {
24+
"now": "^15.2.0",
2425
"npm-run-all": "^4.1.5"
2526
}
26-
}
27+
}

‎packages/server/prisma/seed.ts

+29-29
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
import { prisma } from '../.yoga/prisma-client'
1+
// import { prisma } from '../.yoga/prisma-client'
22

33
async function main() {
4-
await prisma.createUser({
5-
email: 'alice@prisma.io',
6-
name: 'Alice',
7-
posts: {
8-
create: {
9-
title: 'Join us for GraphQL Conf 2019 in Berlin',
10-
content: 'https://www.graphqlconf.org/',
11-
published: true,
12-
},
13-
},
14-
})
15-
await prisma.createUser({
16-
email: 'bob@prisma.io',
17-
name: 'Bob',
18-
posts: {
19-
create: [
20-
{
21-
title: 'Subscribe to GraphQL Weekly for community news',
22-
content: 'https://graphqlweekly.com/',
23-
published: true,
24-
},
25-
{
26-
title: 'Follow Prisma on Twitter',
27-
content: 'https://twitter.com/prisma',
28-
},
29-
],
30-
},
31-
})
4+
// await prisma.createUser({
5+
// email: 'alice@prisma.io',
6+
// name: 'Alice',
7+
// posts: {
8+
// create: {
9+
// title: 'Join us for GraphQL Conf 2019 in Berlin',
10+
// content: 'https://www.graphqlconf.org/',
11+
// published: true,
12+
// },
13+
// },
14+
// })
15+
// await prisma.createUser({
16+
// email: 'bob@prisma.io',
17+
// name: 'Bob',
18+
// posts: {
19+
// create: [
20+
// {
21+
// title: 'Subscribe to GraphQL Weekly for community news',
22+
// content: 'https://graphqlweekly.com/',
23+
// published: true,
24+
// },
25+
// {
26+
// title: 'Follow Prisma on Twitter',
27+
// content: 'https://twitter.com/prisma',
28+
// },
29+
// ],
30+
// },
31+
// })
3232
}
3333

3434
main().catch(e => console.error(e))

‎packages/server/src/context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { yogaContext } from 'yoga'
33

44
export interface Context {
55
prisma: Prisma
6-
req: Request
6+
req: any
77
}
88

99
export default yogaContext(({ req }) => ({
+1-52
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { idArg, prismaObjectType, stringArg } from 'yoga'
1+
import { prismaObjectType } from 'yoga'
22

33
/*
44
type Mutation {
@@ -16,56 +16,5 @@ export const Mutation = prismaObjectType({
1616

1717
// This removes all fields from the underlying Mutation object type
1818
t.prismaFields([])
19-
20-
t.field('deletePost', {
21-
type: 'Post',
22-
nullable: true,
23-
args: {
24-
id: idArg(),
25-
},
26-
resolve: (parent, args, ctx) => {
27-
return ctx.prisma.deletePost({ id: args.id })
28-
},
29-
})
30-
31-
t.field('signupUser', {
32-
type: 'User',
33-
args: {
34-
name: stringArg(),
35-
email: stringArg(),
36-
},
37-
resolve: (parent, { name, email }, ctx) => {
38-
return ctx.prisma.createUser({ name, email })
39-
},
40-
})
41-
42-
t.field('createDraft', {
43-
type: 'Post',
44-
args: {
45-
title: stringArg(),
46-
content: stringArg(),
47-
authorEmail: stringArg(),
48-
},
49-
resolve: (parent, { title, content, authorEmail }, ctx) => {
50-
return ctx.prisma.createPost({
51-
title,
52-
content,
53-
author: { connect: { email: authorEmail } },
54-
})
55-
},
56-
})
57-
58-
t.field('publish', {
59-
type: 'Post',
60-
args: {
61-
id: idArg(),
62-
},
63-
resolve: (parent, { id }, ctx) => {
64-
return ctx.prisma.updatePost({
65-
where: { id },
66-
data: { published: true },
67-
})
68-
},
69-
})
7019
},
7120
})

‎yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -9389,6 +9389,11 @@ normalize-url@^3.0.0:
93899389
version "3.3.0"
93909390
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559"
93919391

9392+
now@^15.2.0:
9393+
version "15.2.0"
9394+
resolved "https://registry.npmjs.org/now/-/now-15.2.0.tgz#3a66859d548a81d222140544a1d84f070a22573a"
9395+
integrity sha512-NAHziNTs2ptFizCvKHjSt69ixl7wG39Zf+hjnetM1ulMFc2jc++bDPPL1m62aQkCPbFwRmuxQtggW1i0/WRU7g==
9396+
93929397
npm-bundled@^1.0.1:
93939398
version "1.0.6"
93949399
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd"

0 commit comments

Comments
 (0)
Please sign in to comment.