All files / src/appsync appSyncClient.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 267x 7x 7x 7x     7x     7x 54x   54x                          
import { AWSAppSyncClient, AUTH_TYPE } from 'aws-appsync';
import { Injectable } from '@nestjs/common';
import 'isomorphic-fetch';
import { EnvironmentService } from '../config';
 
// this is required by appsync sdk subscription
(global as any).WebSocket = require('ws');
 
@Injectable()
export class AppSyncClient {
  constructor(private envService: EnvironmentService) {}
 
  getAppSyncClient = (): Promise<AWSAppSyncClient<any>> => new AWSAppSyncClient({
    url: this.envService.appSyncEndpoint,
    region: this.envService.awsRegion,
    auth: {
      type: AUTH_TYPE.AWS_IAM,
      credentials: {
        accessKeyId: this.envService.iamUserKey,
        secretAccessKey: this.envService.iamUserSecret,
      },
    },
    disableOffline: true,
  }).hydrated();
}