Skip to content

Commit 679714d

Browse files
author
Enda Phelan
committed
feat: use graphback
1 parent 0cf2d68 commit 679714d

Some content is hidden

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

53 files changed

+14123
-7237
lines changed

advanced/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
PRISMA_SECRET="mysecret123"
21
APP_SECRET="jwtsecret123"
2+
MONGODB_CONNECTION_URL="mongodb://mongodb:mongo@localhost:27017/admin"

advanced/.graphqlrc.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
schema: ./src/schema/**/*.graphql
2+
extensions:
3+
# Graphback configuration
4+
graphback:
5+
## Input schema
6+
model: ./model
7+
## Global configuration for CRUD generator
8+
crud:
9+
create: true
10+
update: true
11+
findAll: true
12+
find: true
13+
delete: true
14+
subCreate: true
15+
subUpdate: true
16+
subDelete: true
17+
## Codegen plugins
18+
plugins:
19+
graphback-schema:
20+
format: 'graphql'
21+
outputPath: ./src/schema
22+
graphback-resolvers:
23+
format: ts
24+
outputPath: ./src/resolvers

advanced/.install/index.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

advanced/.install/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

advanced/.install/yarn.lock

Lines changed: 0 additions & 110 deletions
This file was deleted.

advanced/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3'
2+
services:
3+
mongodb:
4+
image: mongo:latest
5+
container_name: "mongodb"
6+
environment:
7+
- MONGO_DATA_DIR=/data/db
8+
- MONGO_LOG_DIR=/dev/null
9+
- MONGO_INITDB_DATABASE=users
10+
- MONGO_INITDB_ROOT_USERNAME=mongodb
11+
- MONGO_INITDB_ROOT_PASSWORD=mongo
12+
volumes:
13+
- ./data/db:/data/db
14+
ports:
15+
- 27017:27017
16+
command: mongod

advanced/model/datamodel.graphql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
scalar DateTime
2+
3+
"""
4+
@model
5+
"""
6+
type Post {
7+
id: ID!
8+
createdAt: DateTime
9+
updatedAt: DateTime
10+
published: Boolean!
11+
title: String!
12+
content: String!
13+
}
14+
15+
"""
16+
@model
17+
"""
18+
type User {
19+
id: ID!
20+
email: String!
21+
password: String!
22+
name: String!
23+
"""
24+
@oneToMany field: 'author'
25+
"""
26+
posts: [Post!]!
27+
}

advanced/package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,27 @@
33
"scripts": {
44
"start": "dotenv -- nodemon -e ts,graphql -x ts-node src/index.ts",
55
"debug": "dotenv -- nodemon -e ts,graphql -x ts-node --inspect src/index.ts",
6-
"build": "rimraf dist && tsc"
6+
"build": "rimraf dist && tsc",
7+
"generate": "graphback generate"
78
},
89
"dependencies": {
10+
"@graphback/runtime-mongo": "0.11.2",
11+
"apollo-server-express": "2.11.0",
912
"bcryptjs": "2.4.3",
10-
"graphql-yoga": "1.18.3",
11-
"jsonwebtoken": "8.5.1"
13+
"graphql": "14.6.0",
14+
"graphql-config": "3.0.0-alpha.23",
15+
"graphql-iso-date": "^3.6.1",
16+
"jsonwebtoken": "8.5.1",
17+
"mongodb": "3.5.5"
1218
},
1319
"devDependencies": {
1420
"@types/bcryptjs": "2.4.2",
1521
"@types/node": "10.17.18",
1622
"dotenv-cli": "1.4.0",
23+
"graphback-cli": "0.11.4",
1724
"nodemon": "1.19.4",
18-
"prisma": "1.34.10",
1925
"rimraf": "2.7.1",
26+
"schemats": "3.0.3",
2027
"ts-node": "7.0.1",
2128
"typescript": "3.2.2"
2229
}

advanced/prisma/datamodel.prisma

Lines changed: 0 additions & 17 deletions
This file was deleted.

advanced/prisma/prisma.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

advanced/prisma/seed.graphql

Lines changed: 0 additions & 34 deletions
This file was deleted.

advanced/seed.graphql

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Write your query or mutation here
2+
mutation {
3+
user1: createUser(input: {
4+
5+
name: "Alan"
6+
password: "$2b$10$dqyYw5XovLjpmkYNiRDEWuwKaRAvLaG45fnXE5b3KTccKZcRPka2m" # "secret42"
7+
}) {
8+
id
9+
}
10+
11+
user1Post: createPost(input: {
12+
title: "Graphback - the evolution of the GraphQL ecosystem"
13+
content: "https://graphback.dev/blog/2019/08/21/introduction"
14+
published: true
15+
}) {
16+
title
17+
content
18+
}
19+
20+
user2: createUser(input: {
21+
22+
name: "Siobhan"
23+
password: "$2b$10$o6KioO.taArzboM44Ig85O3ZFZYZpR3XD7mI8T29eP4znU/.xyJbW" # "secret43"
24+
}) {
25+
id
26+
}
27+
28+
user2Post: createPost(input: {
29+
title: "Graphback - Low Code, GraphQL based API suited for your needs"
30+
content: "https://graphback.dev/blog/2020/02/06/graphback-plugins"
31+
published: true
32+
}) {
33+
title
34+
content
35+
}
36+
}

0 commit comments

Comments
 (0)