@speakbox/nestjs-hasura
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

NestJS Hasura

Installation

npm install @speakbox/nestjs-hasura

Usage

Import the module and the service in your NestJS application:

import { Module } from '@nestjs/common';
import { HasuraModule, HasuraService } from '@speakbox/nestjs-hasura';

@Module({
  imports: [HasuraModule],
  providers: [HasuraService],
})
export class AppModule {}

Using the service

import { Inject, Injectable } from "@nestjs/common";
import { HasuraService } from '@speakbox/nestjs-hasura';

@Injectable()
export class ExampleService {
  constructor(
    @Inject(HasuraService) private readonly hasura: HasuraService,
  ) {}
  
  exampleRequest() {
    return this.hasura.request(
      gql`query SomeQuery($id: bigint!) {
        some_resource_by_pk(id: $id) {
          id
          name
        }
      }`,
      { id: 1}
    );
  }
}

For more information on how to use the service, please refer to the NestJS Documentation.

Environment variables

This package relies on environment variables to configure Hasura:

# Hasura API endpoint
HASURA_GRAPHQL_ENDPOINT=https://hasura.example.com/v1/graphql

# Hasura API Admin Secret
HASURA_GRAPHQL_ADMIN_SECRET=my-secret

Change Log

See Changelog for more information.

Contributing

Contributions welcome! See Contributing.

Author

Valentin Prugnaud @valentinprgnd

License

Licensed under the MIT License - see the LICENSE file for details.

Dependencies (1)

Dev Dependencies (24)

Package Sidebar

Install

npm i @speakbox/nestjs-hasura

Weekly Downloads

22

Version

3.1.0

License

MIT

Unpacked Size

16.3 kB

Total Files

20

Last publish

Collaborators

  • foxted