Skip to content

Commit bfaa760

Browse files
committed
Here it is, the admin backend fetches the entities from the graphql backend, next step, add new entities from admin
1 parent cee4974 commit bfaa760

File tree

17 files changed

+596
-103
lines changed

17 files changed

+596
-103
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
*.sqlite3
33
yarn-error.log
44
.parcel-cache
5-
dist
5+
dist
6+
__generated__

babel.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
}
99
]
1010
],
11-
"plugins": ["@parcel/babel-plugin-transform-runtime"]
11+
"plugins": ["relay", "@parcel/babel-plugin-transform-runtime"]
1212
}

docker/.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
DEBUG=1
22
BACKEND_PORT=4000
33
ADMIN_PORT=1234
4-
SCHEMA_CONFIG_DB_PATH=/db/backend-graphql.sqlite3
4+
SCHEMA_CONFIG_DB_PATH=/db/backend-graphql.sqlite3
5+
BACKEND_GQL_API_URL=http://localhost:4000/backend/graphql

docker/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ services:
2828
command: yarn admin -p ${ADMIN_PORT}
2929
ports:
3030
- ${ADMIN_PORT}:${ADMIN_PORT}
31+
environment:
32+
- BACKEND_GQL_API_URL=${BACKEND_GQL_API_URL}
33+
- COMPILE_RELAY=1
3134

3235
volumes:
3336
db:

docker/entrypoint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ set -e
44
cd /app
55
yarn install
66

7+
if [ ! -z $COMPILE_RELAY ]; then
8+
yarn relay
9+
fi
10+
711
# run the provided cmd
812
exec "$@"

nodemon.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignore": [".git", "node_modules/**/node_modules"],
3+
"watch": ["repos/nodejs", "repos/libs"],
4+
"ext": "js,mjs"
5+
}

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010
"@babel/preset-react": "^7.13.13",
1111
"@parcel/babel-plugin-transform-runtime": "^2.0.0-nightly.1823",
1212
"@parcel/babel-preset-env": "^2.0.0-alpha.3",
13+
"babel-plugin-relay": "^11.0.2",
14+
"get-graphql-schema": "^2.1.2",
1315
"nodemon": "^2.0.7",
1416
"parcel": "^2.0.0-nightly.678",
17+
"relay-compiler": "^11.0.2",
1518
"sqlite3": "^5.0.2"
1619
},
1720
"scripts": {
1821
"server": "nodemon ./repos/nodejs/server/src/index.mjs",
19-
"admin": "parcel ./repos/react/admin/src/index.html"
22+
"admin": "parcel ./repos/react/admin/src/index.html",
23+
"admin_gql_schema": "get-graphql-schema $(cat docker/.env | grep BACKEND_GQL_API_URL | cut -d'=' -f 2) > ./repos/react/admin/schema.graphql",
24+
"relay": "relay-compiler --src ./repos/react/admin/src --schema ./repos/react/admin/schema.graphql --extensions jsx"
2025
}
2126
}

repos/nodejs/backend-graphql/src/models/entity.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { DataTypes } = sequelize;
33

44
const entity = (db) =>
55
db.define("Entity", {
6-
id: {
6+
_id: {
77
type: DataTypes.INTEGER,
88
primaryKey: true,
99
autoIncrement: true,

repos/nodejs/backend-graphql/src/schema.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { buildSchema } from "graphql";
22

33
const types = `
44
type Entity {
5-
id: Int
5+
_id: Int
66
name: String
77
}
88
`;

repos/nodejs/server/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"name": "@agql.js/server",
33
"version": "1.0.0",
44
"dependencies": {
5-
"express": "^4.17.1",
65
"@agql.js/backend-graphql": "^1.0.0",
7-
"@agql.js/graphql": "^1.0.0"
6+
"@agql.js/graphql": "^1.0.0",
7+
"cors": "^2.8.5",
8+
"express": "^4.17.1"
89
},
910
"main": "src/index.mjs"
1011
}

0 commit comments

Comments
 (0)