Hasura - calling from Express

Viewed 1309

Getting my feet wet with Hasura, working on creating an JWT auth server. Please let me know if I'm on the wrong track anywhere here, I'm still navigating this architecture.

So what I have is:

  • Hasura GraphQL Engine
  • Postgres database
  • Node Express server

From reading the Hasura docs on authentication, it describes needing another service that provides the JWT token that the client uses to access Hasura. So I'm rolling with that paradigm, implementing an Auth service using NodeJS.

Users are managed in the same Postgres database hooked into Hasura. What makes sense to me is that my Auth service connects to Hasura for some User related operations (fetch to check login credentials, and User creation since the hashing algorithm should be in one place). So the question here is, how should I be connecting to Hasura from Express? I only found one example that's a little rough... also I would want to avoid connecting directly to Postgres, as it would somewhat defeat the purpose of Hasura (I intend to creating an Auth role that only the Auth service has credentials for).

Would it make sense to use apollo-server in this scenario? I don't necessarily want to create a full GraphQL server (having Hasura already), I would only want those specific operations to be accessible. I'm also green with GraphQL which accounts for some of my floundering here. Any advice is appreciated!

0 Answers
Related