@worktif/purews
Version:
Work TIF TypeScript-based AWS infrastructure toolkit featuring DynamoDB integration, AppSync support, SES functionality, and GraphQL capabilities with comprehensive audit logging and AWS Signature V4 authentication.
83 lines (82 loc) • 3.96 kB
TypeScript
import 'reflect-metadata';
import { BeforeInstance, GqlToVoid, LoggerInterface, Serializer } from '@worktif/utils';
import { GqlInputKeys, GqlMutationResult, GqlQueryResult, ModelConditionInput } from '@utils/graphql';
import { Logger } from '@aws-lambda-powertools/logger';
import { EnvConfigPurews } from '@config/env.config.purews';
import { GraphQlSerializer } from './app-sync.service.types';
export declare class AppSyncService implements LoggerInterface {
protected envConfig: EnvConfigPurews;
protected serializer: Serializer;
/**
* Represents an instance of a logger.
* @type {Logger}
*/
loggerInstance: Logger;
/**
* AWSAppSyncClient
*
* Represents a client for interacting with AWS AppSync service.
*
* @type {AWSAppSyncClient<NormalizedCacheObject>}
*/
private appSyncClient;
/**
* Represents the authentication token for accessing secure resources.
* @type {string}
*/
private authToken;
private dump;
/**
* Constructor for initializing a new class instance.
*
* @param {EnvConfigPurews} envConfig The environment configuration settings.
* @param {Serializer} serializer The GraphQL merchants serializer.
* @return {AppSyncService} A new instance of the class with the specified environment configuration and GraphQL merchants serializer.
*/
constructor(envConfig: EnvConfigPurews, serializer: Serializer);
/**
* Executes a query against an AppSync endpoint using the provided options.
*
* @param queryOptions
* @param serializer
* @param deserializer
* @param beforeInstance An optional instance to perform actions before the query execution.
* @return A Promise that resolves with the result of the query as an ApolloQueryResult.
*/
query<TResult extends object = any, TVariables extends GqlInputKeys = GqlInputKeys>({ query, payload }: {
query: string;
payload: TVariables;
}, { serializer, deserializer, }?: GraphQlSerializer<TResult, TVariables, any, any>, beforeInstance?: BeforeInstance): Promise<GqlQueryResult<TResult, TResult>>;
/**
* Mutates data using AWS AppSync service based on the provided mutation and payload.
*
* @param {Object} mutation - The GraphQL mutation to be executed.
* @param {Object} payload - The variables associated with the mutation.
* @param serializer - Serializer function for data serialization.
* @param deserializer - Deserializer function for data deserialization.
* @param payloadSerializer - The payload serializer instance.
* @param {BeforeInstance} [beforeInstance] - Instance of BeforeInstance for logging purposes.
*
* @return {Promise<Maybe<FetchResult<TResult>>>} A Promise resolving to the fetch result of the mutation operation.
*/
mutate<TResult extends object = any, TVariables extends object = any>({ mutation, payload, conditions, }: {
mutation: string;
payload: TVariables;
conditions?: ModelConditionInput<TResult>;
}, { serializer, deserializer, }?: GraphQlSerializer<TResult, TVariables, any, any>, beforeInstance?: BeforeInstance): Promise<GqlMutationResult<GqlToVoid<TResult>>>;
/**
* Create a MutationInternal object based on the given mutationString.
*
* @param {string} mutationString The GraphQL mutation string to create the MutationInternal from.
* @return {MutationInternal<TInput>} Returns a MutationInternal object containing keys and the mutation document.
* @private
*/
private createMutationInternal;
/**
* Creates an internal query object based on the provided GraphQL query string.
*
* @param {string} queryString - The GraphQL query string to be parsed.
* @return {QueryInternal<TInput>} - An object containing the input keys, output key, and the parsed query document.
*/
private createQueryInternal;
}