Setup first hasura schema

This commit is contained in:
Charles Bochet 2023-04-13 18:12:33 +02:00 committed by Anders Borch
parent b9d1d80f64
commit 0445c03b51
26 changed files with 92 additions and 25 deletions

View File

@ -6,6 +6,7 @@ Welcome to Twenty documentation!
Twenty development stack is composed of 3 different layers
- front: our frontend React app
- hasura: our graphql engine exposing our database and server
- server: our backend that contain endpoint, crm logic, scripts, jobs...
- storages: postgres
@ -29,7 +30,7 @@ cd infra/dev
```
```
docker-compose up --build --force-recreate
make build
```
Once this is completed you should have:
@ -46,23 +47,16 @@ If you are using VSCode, please use the `Dev Containers` extension to open the p
If you are using Docker install, make sure to ssh in the docker container during development to execute commands. You can also use `Makefile` to help you
## Development
## Development workflow
### Tests
### Front tests
#### Unit tests:
Run tests: `make front-test`
Run coverage: `make front-coverage`
Run storybook: `make front-storybook`
```
make front-test
# coverage
make front-coverage
```
### Hasura development
#### Storybook:
```
make front-storybook
```
## Developping on server
Section TBD
Open hasura console: `make hasura-console`
Do your changes in hasura console on http://localhost:9695
Commit your changes in git

6
hasura/config.yaml Normal file
View File

@ -0,0 +1,6 @@
version: 3
endpoint: http://localhost:8080
metadata_directory: metadata
actions:
kind: synchronous
handler_webhook_baseurl: http://localhost:3000

View File

View File

@ -0,0 +1,6 @@
actions: []
custom_types:
enums: []
input_objects: []
objects: []
scalars: []

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1,9 @@
- name: twenty
kind: postgres
configuration:
connection_info:
database_url:
from_env: HASURA_GRAPHQL_PG_DATABASE_URL
isolation_level: read-committed
use_prepared_statements: false
tables: "!include twenty/tables/tables.yaml"

View File

@ -0,0 +1,3 @@
table:
name: workspaces
schema: public

View File

@ -0,0 +1 @@
- "!include public_workspaces.yaml"

View File

@ -0,0 +1 @@
disabled_for_roles: []

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1 @@
version: 3

View File

@ -0,0 +1 @@
DROP TABLE "public"."workspaces";

View File

@ -0,0 +1 @@
CREATE TABLE "public"."workspaces" ("id" serial NOT NULL, "name" Text NOT NULL, "display_name" text NOT NULL, PRIMARY KEY ("id") , UNIQUE ("id"), UNIQUE ("name"));

View File

@ -1,17 +1,39 @@
build: ##
@docker-compose up --build --force-recreate
up: ##
@docker-compose up -d
logs: ##
@docker-compose logs twenty -f
down: ##
@docker-compose down
sh: ##
@docker-compose exec twenty sh
## Front
front-logs: ##
@docker-compose logs twenty-front -f
front-sh: ##
@docker-compose exec twenty-front sh
front-test: ##
@docker-compose exec twenty sh -c "cd front && npm run test"
@docker-compose exec twenty-front sh -c "npm run test"
front-coverage: ##
@docker-compose exec twenty sh -c "cd front && npm run coverage"
@docker-compose exec twenty-front sh -c "npm run coverage"
front-storybook: ##
@docker-compose exec twenty sh -c "cd front && npm run storybook"
@docker-compose exec twenty-front sh -c "npm run storybook"
## Hasura
hasura-logs: ##
@docker-compose logs twenty-hasura -f
hasura-sh: ##
@docker-compose exec twenty-hasura sh
hasura-console: ##
@docker-compose exec twenty-hasura bash -c " \
socat TCP-LISTEN:9695,fork,reuseaddr,bind=twenty-hasura TCP:127.0.0.1:9695 & \
socat TCP-LISTEN:9693,fork,reuseaddr,bind=twenty-hasura TCP:127.0.0.1:9693 & \
hasura console --log-level DEBUG --address "127.0.0.1" --no-browser || exit 1"

View File

@ -26,7 +26,7 @@ services:
environment:
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/hasura
HASURA_GRAPHQL_PG_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/twenty
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
twenty-server:

View File

@ -6,4 +6,6 @@ RUN apt-get install -y socat
RUN apt-get install -y vim
RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
WORKDIR /hasura
CMD ["sh", "-c", "graphql-engine serve"]

View File

@ -0,0 +1,9 @@
FROM hasura/graphql-engine:latest as api
RUN apt-get update
RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
WORKDIR /app/hasura
COPY ./hasura .
CMD ["sh", "-c", "graphql-engine serve"]