npm install @speakbox/nestjs-hasura
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 {}
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.
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
See Changelog for more information.
Contributions welcome! See Contributing.
Valentin Prugnaud @valentinprgnd
Licensed under the MIT License - see the LICENSE file for details.