Closed banjtheman closed 3 years ago
Can I take up this issue? @banjtheman
Hey @banjtheman to edit the environment variable HASURA_GRAPHQL_DATABASE_URL for connecting to Postgres instance, I need information regarding DB_URL and password, can we connect on discord for same.
The command is as follows :-
docker run -d -p 8080:8080 \
-e HASURA_GRAPHQL_DATABASE_URL=postgres://username:password@hostname:port/dbname \
-e HASURA_GRAPHQL_ENABLE_CONSOLE=true \
hasura/graphql-engine:latest
You would stand up the API service as follows...
docker-compose -f docker-compose.api.yml up -d
https://github.com/banjtheman/defundthepolice/blob/main/docker-compose.api.yml
Ultimately you would add that image to the docker-compose file
Hey @banjtheman I added the image in docker-compose but it exits every time, with the log mentioning "database query error". Can you guide me on this, please?
Changes: docker-compose-api.yml
version: "3"
services:
postgres:
build:
context: .
dockerfile: ./docker/postgres/Dockerfile
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=1234
- POSTGRES_DB=dfp
ports:
- "5432"
api:
build:
context: .
dockerfile: ./docker/api/Dockerfile
environment:
- DB_USERNAME=postgres
- DB_PASSWORD=1234
- DB_HOST=postgres
- DB_PORT=5432
- DB_DATABASE=dfp
ports:
- "9000:9000"
volumes:
- ".:/app"
command: "gunicorn --bind 0.0.0.0:9000 api.budgetsdata:application"
links:
- postgres
graphql-engine:
image: hasura/graphql-engine:v1.3.2
ports:
- "8080:8080"
depends_on:
- "postgres"
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:1234@postgres:5432/dfp
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_DEV_MODE: "true"
Docker Logs: https://www.writeurl.com/text/8rd87t5yzwu21vjdpe4b/x7kxe0oa5uqo95zpd2o6/e9l9rpi6o5heol88o3na
Current Status:
hmm looks like the main app started, shouldn't need to start that. Also, you can inspect the logs of the Hasura image using
docker logs IMAGE_ID
to get a better understanding of the issue.
Hey @banjtheman The docker container for GraphQL keeps on exiting because of database query error as per logs
"error":{"exec_status":"FatalError","hint":null,"message":"syntax error at or near \"WITH ORDINALITY\"","status_code":"42601","description":null},"arguments":[]},"path":"$","error":"database query error","code":"unexpected"}
Containers Status:
Can I connect with you to discuss how to take this forward?
The issue was that Postgres needed to be version 12 instead of 9.3 PR #59 fixes this issue
What is the Task
Follow the guide to create a GraphQL endpoint for our Postgres database
https://hasura.io/docs/1.0/graphql/core/deployment/deployment-guides/docker.html#deployment-docker
Why do we want to do this
To have a more gruanular api
How can I get started?
Follow the steps outlined here https://hasura.io/docs/1.0/graphql/core/deployment/deployment-guides/docker.html#deployment-docker
Definition of Done
Can send GraphQL requests to the endpoint