Nx Plugin for Hasura
The Nx Plugin for Hasura contains generators for managing Hasura services and sdk within an Nx workspace. It provides:
- Integration with tools such as GraphQL Code Generator
- Scaffolding for sdk based on GraphQL API as library
- Scaffolding for hasura metadata and migration folder in services
- Utilities for environments based migrations
#
Adding the Hasura pluginAdding the Hasura plugin to a workspace can be done with the following:
#yarnyarn add -D @raftlabs/nx-hasura
#npmnpm install -D @raftlabs/nx-hasura
The file structure for a Hasura application looks like:
myorgโโโ appsโโโ libsโโโ nx.jsonโโโ package.jsonโโโ package-lock.jsonโโโ README.mdโโโ servicesโ โโโ hasuraโ โโโ config.yamlโ โโโ metadataโ โโโ actions.graphqlโ โโโ actions.yamlโ โโโ allow_list.yamlโ โโโ cron_triggers.yamlโ โโโ databasesโ โ โโโ databases.yamlโ โโโ query_collections.yamlโ โโโ remote_schemas.yamlโ โโโ version.yamlโโโ toolsโ โโโ generatorsโ โโโ tsconfig.tools.jsonโโโ tsconfig.base.jsonโโโ workspace.json
#
Executors / Builders- hasura - exposes hasura cli with preloaded environment
- console - start hasura local console environment
- migrate - run hasura migrate & metadata command on environment
- generate - run graphql generator and update the sdk
#
Generators- application - Create an Hasura service
- sdk - Create an GraphQL based sdk in lib & configure graphql code generator