2

Existing project managed with hasura{cli, console}. Already migrated pg database from heroku-to-supabase.

The goal is to use SupabaseClient on the backend (with NextApiRequest handlers) for image/uploads

supabaseClient.storage.from(bucketId).upload(filePath, file, {
        contentType,
      })

I want to continue with apollo/client on the front.

Errors and problems encountered while setting local environment and trying to connect hasura/graphql-engine with supabase_network_app and more importantly supabase_db_app while removing current postgres image from docker-compose.yml:

  • supabase_db_app refusing connection
  • invalid response was received from the upstream server
    • cause: supabase_auth_app image.
    • ERROR: no schema has been selected to create
    • ERROR: Migrator: problem creating schema migrations
  • ERROR: extension "pg_graphql" must be installed in schema "graphql"
  • postgres local port 54322 failed: received invalid response to SSL negotiation

[wip] solution: supabase init and start as per supabase documentation

/docker-compose.yml

version: '3.6'
services:
  hasura:
    image: hasura/graphql-engine:v2.15.1
    container_name: hasura
    networks:
      - default
      - supabase_network_app
    ports:
      - 8081:8080 # supabase_pg_meta_app also runs on 8080/tcp
    # depends_on:
    #   - "postgres"
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgres@192.168.0.2:5432/postgres
      #feel free to replace/test with:       postgres://postgres:postgres@host.docker.internal:54322/postgres
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
      HASURA_GRAPHQL_ENABLE_REMOTE_SCHEMA_PERMISSIONS: "true"
      HASURA_GRAPHQL_DEV_MODE: "true"
      HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
      HASURA_GRAPHQL_ADMIN_SECRET: $HASURA_GRAPHQL_ADMIN_SECRET
      HASURA_GRAPHQL_JWT_SECRET: '{ "type": "RS512", "jwk_url": "$AUTH0_ISSUER_BASE_URL/.well-known/jwks.json" }'
 
networks:
  supabase_network_app:
    name: supabase_network_app
    external: true
    driver: bridge

Apply migration/metadata/seeds as usual with hasura

to keep things consistent and avoid manually applying and granting pg storage permissions: create dump from supabase ref:

pg_dump --clean --if-exists --quote-all-identifiers \
 -h SUPABASE_URL -U postgres -d postgres \
  > supabase_dump.sql

and apply to local dev:

psql -h localhost -p 54322 -U postgres -f supabase_dump.sql
  • this also helps supabase_auth_app container to start with no errors.

What's your experience with hasura/graphql-engine and supabase in local dev?

renderVis
  • 21
  • 4

0 Answers0