Open4

hasura覚書

mattakmattak

user roleでリクエストするときのheader

x-hasura-default-role: user
x-hasura-allowed-roles: ["user"]
x-hasura-user-id: <FIXME>
Authorization: Bearer <FIXME>
mattakmattak

JWT tokenをFirebaseAuthで利用する際は、1hで有効期限が切れるので注意する.

mattakmattak

docker-compose.yml

version: '3.6'
services:
  postgres:
    image: postgres:14
    restart: always
    volumes:
    - db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: <FIXME>
    ports:
    - "5432:5432"
  graphql-engine:
    image: hasura/graphql-engine:v2.19.0
    ports:
    - "8080:8080"
    depends_on:
    - "postgres"
    restart: always
    environment:
      PG_DATABASE_URL: $PG_DATABASE_URL
      HASURA_GRAPHQL_METADATA_DATABASE_URL: $HASURA_GRAPHQL_METADATA_DATABASE_URL
      HASURA_GRAPHQL_ADMIN_SECRET: $HASURA_GRAPHQL_ADMIN_SECRET
      HASURA_GRAPHQL_CORS_DOMAIN: $HASURA_GRAPHQL_CORS_DOMAIN
      HASURA_GRAPHQL_JWT_SECRET: $HASURA_GRAPHQL_JWT_SECRET
      HASURA_GRAPHQL_DEV_MODE: "true"
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
      HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
volumes:
  db_data:
mattakmattak

本番環境ではHASURA_GRAPHQL_ENABLE_CONSOLEはfalseにする
つなぎたかったらhasura cliを利用してつなぐ

hasura $@ \
  --log-level "DEBUG" \
  --admin-secret "$HASURA_GRAPHQL_ADMIN_SECRET" \
  --endpoint "$HASURA_ENDPOINT"