Class: Loader
Load resolvers into an AppSync GraphQL API construct.
import { Loader } from '@appsync-butler/core';
import { GraphqlApi } from '@aws-cdk/aws-appsync-alpha';
import { Table } from '@aws-cdk/aws-dynamodb';
const graphqlApi = new GraphqlApi(...);
const userTable = new Table(...);
const orderTable = new Table(...);
const userDs = graphqlApi.addDynamoDbDataSource('userDs', table);
const orderDs = graphqlApi.addDynamoDbDataSource('orderDs', table);
const loader = new Loader(appStack, {
api: graphqlApi,
defaultUnitResolverDataSource: tableDs,
defaultFunctionDataSource: 'none',
dataSources: {
orders: orderDs
},
variables: {
tableName: table.tableName
}
});
loader.load();
Constructors
new Loader()
new Loader(
scope,options):Loader
Parameters
scope
Construct
A CDK construct. Usually, it is the stack instance.
options
Loading, parsing, or reading directives.
Returns
Properties
api
protectedreadonlyapi:GraphqlApi
The passed API instance.
builder
readonlybuilder:Builder
The underlying builder instance that is responsible for building the resolver tree and function dictionary.
dataSources?
protectedreadonlyoptionaldataSources:Record<string,BaseDataSource>
Data source dictionary
defaultFunctionDs?
readonlyoptionaldefaultFunctionDs:DataSource
The passed default function data source.
defaultUnitResolverDs?
readonlyoptionaldefaultUnitResolverDs:DataSource
The passed default unit resolver data source.
functions
readonlyfunctions:Record<string,AppsyncFunction> ={}
The created Appsync Functions. Only populated after loading.
noneDs?
protectedoptionalnoneDs:BaseDataSource
None data source object. Created and reused when necessary.
scope
protectedreadonlyscope:Construct
The passed scope. Used when creating Appsync Functions
Methods
addFunction()
protectedaddFunction(func):void
Parameters
func
Returns
void
addResolver()
protectedaddResolver(resolver):void
Parameters
resolver
Returns
void
getAppSyncFunction()
protectedgetAppSyncFunction(name):AppsyncFunction
Parameters
name
string
Returns
AppsyncFunction
getFunctionDataSource()
protectedgetFunctionDataSource(func):NonNullable<undefined|DataSource>
Parameters
func
Returns
NonNullable<undefined | DataSource>
getMappingTemplate()
Call Signature
protectedgetMappingTemplate(data):MappingTemplate
Parameters
data
string
Returns
MappingTemplate
Call Signature
protectedgetMappingTemplate(data):undefined
Parameters
data
undefined
Returns
undefined
Call Signature
protectedgetMappingTemplate(data):undefined|MappingTemplate
Parameters
data
undefined | string
Returns
undefined | MappingTemplate
getNoneDs()
protectedgetNoneDs():BaseDataSource
Returns
BaseDataSource
getResolverProps()
protectedgetResolverProps(resolver):Omit<BaseResolverProps,"fieldName"|"typeName">
Parameters
resolver
Returns
Omit<BaseResolverProps, "fieldName" | "typeName">
getUnitResolverDataSource()
protectedgetUnitResolverDataSource(resolver):NonNullable<undefined|DataSource>
Parameters
resolver
Returns
NonNullable<undefined | DataSource>