{"id":13479327,"url":"https://github.com/zenflow/hasura-node-monolith-example","last_synced_at":"2025-03-19T03:30:28.209Z","repository":{"id":39849526,"uuid":"264499334","full_name":"zenflow/hasura-node-monolith-example","owner":"zenflow","description":"Example of a monolithic web application using Hasura GraphQL Engine + Node.js + Next.js","archived":false,"fork":false,"pushed_at":"2023-03-04T19:16:48.000Z","size":1536,"stargazers_count":31,"open_issues_count":6,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-19T14:35:01.117Z","etag":null,"topics":["apollo","apollo-graphql","graphql","hasura","hasura-graphql","hasura-graphql-engine","mono","monolith","monorepo","next-auth","nextjs","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://hasura-node-monolith-example.matthewbrunetti.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-16T18:20:03.000Z","updated_at":"2024-04-14T16:43:49.000Z","dependencies_parsed_at":"2024-01-06T20:54:58.755Z","dependency_job_id":null,"html_url":"https://github.com/zenflow/hasura-node-monolith-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fhasura-node-monolith-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fhasura-node-monolith-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fhasura-node-monolith-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fhasura-node-monolith-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenflow","download_url":"https://codeload.github.com/zenflow/hasura-node-monolith-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243961575,"owners_count":20375271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","apollo-graphql","graphql","hasura","hasura-graphql","hasura-graphql-engine","mono","monolith","monorepo","next-auth","nextjs","nodejs","typescript"],"created_at":"2024-07-31T16:02:13.704Z","updated_at":"2025-03-19T03:30:27.613Z","avatar_url":"https://github.com/zenflow.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Templates and Examples"],"sub_categories":[],"readme":"# hasura-node-monolith-example\n\nThis is a sample fullstack web application incorporating the following:\n\n- [Hasura GraphQL Engine](https://hasura.io/docs/latest/graphql/core/index.html) for a data backend\n- Node.js server to handle custom [Hasura Actions](https://hasura.io/docs/latest/graphql/core/actions/index.html)\n- Authentication server using [NextAuth.js](https://next-auth.js.org/), handles [Hasura's auth webhook](https://hasura.io/docs/latest/graphql/core/auth/authentication/webhook.html#configuring-webhook-mode) to define client's user id \u0026 role for Hasura\n- UI frontend using [TypeScript](https://www.typescriptlang.org/), [Next.js](https://nextjs.org/), [Apollo \\[GraphQL\\] Client](https://www.apollographql.com/docs/react/), and [GraphQL Code Generator](https://www.graphql-code-generator.com/)\n- _All rolled into a single dockerized service, for simplified deployment, using [composite-service](https://github.com/zenflow/composite-service)_\n\n#### Check out my [Production Deployment](https://hasura-node-monolith-example.matthewbrunetti.com/)\n\n## Architecture Notes\n\n- Hasura's auth webhook is used (as opposed to configuring Hasura to read JWT claims directly)\n  because it allows the user's role to be dynamic.\n  This way (supposing we had more roles in the app) users won't have to sign out \u0026 sign in when their role changes.\n  We can also easily implement user or token blocklists if required.\n\n## Local development\n\nRequires [Node.js](https://nodejs.org/en/) \u003e= v14, yarn package manager v1, \u0026 docker ( [Docker Desktop](https://docs.docker.com/desktop/) \u003e= v3.2 for Windows \u0026 Mac, or [Docker Engine](https://docs.docker.com/engine/) \u003e= v19.03 for Linux).\n\nCopy contents of [`.env.example`](./.env.example) to `.env` and optionally fill in values (defaults should work).\n\n`yarn install`\n\nStart development db with `yarn db` (needs to be running for either of next two tasks)\n\nStart app in dev mode with `yarn dev`, *or* start app in production mode with `yarn start`.\n\nWhen the app is started in dev mode:\n\n- The [Hasura Console](https://hasura.io/docs/latest/graphql/core/hasura-cli/hasura_console.html)\n(Hasura's web UI) will be opened in a browser tab along with the Next.js web app.\n- Changes made via the Hasura Console will be reflected in changes in\n`hasura/migrations/` \u0026 `hasura/metadata/` which can be committed to Git.\nThese migrations \u0026 metadata are applied whenever the app starts, for both dev mode \u0026 production,\nusing Hasura's [cli-migrations image](https://hasura.io/docs/latest/graphql/core/migrations/advanced/auto-apply-migrations.html).\n- The TypeScript types for GraphQL queries/mutations/fragments (in `web/graphql/generated.ts`)\nwill be regenerated whenever there are edits to a `.graphql` file.\n- You can execute other [hasura-cli](https://hasura.io/docs/latest/graphql/core/hasura-cli/index.html)\ncommands with `yarn _hasura`, e.g. `yarn _hasura seed apply` or `yarn _hasura --help`.\n\n## Production deployment\n\nUse the Dockerfile in the project root\nand define the variables documented in [`.env.example`](./.env.example).\n\n### With Heroku\n\n- This project is ready to deploy without code changes (i.e. includes [heroku.yml](./heroku.yml))\n- Create app in Heroku web ui, and **before connecting to repo**,\nrun (in any directory) `heroku stack:set container -a your-app-name-here`.\nThen you can (in Heroku web ui) connect app to repo (under \"Deploy\" tab -\u003e \"Deployment method\").\n- Heroku Postgres will define the `DATABASE_URL` environment variable. Be sure to copy it to `HASURA_GRAPHQL_DATABASE_URL`\n- Set environment variable `HASURA_GRAPHQL_CLI_ENVIRONMENT=default` as per\n[hasura/graphql-engine#4651](https://github.com/hasura/graphql-engine/issues/4651#issuecomment-623414531)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenflow%2Fhasura-node-monolith-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenflow%2Fhasura-node-monolith-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenflow%2Fhasura-node-monolith-example/lists"}