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
protected
readonly
api:GraphqlApi
The passed API instance.
builder
readonly
builder:Builder
The underlying builder instance that is responsible for building the resolver tree and function dictionary.
dataSources?
protected
readonly
optional
dataSources:Record
<string
,BaseDataSource
>
Data source dictionary
defaultFunctionDs?
readonly
optional
defaultFunctionDs:DataSource
The passed default function data source.
defaultUnitResolverDs?
readonly
optional
defaultUnitResolverDs:DataSource
The passed default unit resolver data source.
functions
readonly
functions:Record
<string
,AppsyncFunction
> ={}
The created Appsync Functions. Only populated after loading.
noneDs?
protected
optional
noneDs:BaseDataSource
None data source object. Created and reused when necessary.
scope
protected
readonly
scope:Construct
The passed scope. Used when creating Appsync Functions
Methods
addFunction()
protected
addFunction(func
):void
Parameters
func
Returns
void
addResolver()
protected
addResolver(resolver
):void
Parameters
resolver
Returns
void
getAppSyncFunction()
protected
getAppSyncFunction(name
):AppsyncFunction
Parameters
name
string
Returns
AppsyncFunction
getFunctionDataSource()
protected
getFunctionDataSource(func
):NonNullable
<undefined
|DataSource
>
Parameters
func
Returns
NonNullable
<undefined
| DataSource
>
getMappingTemplate()
Call Signature
protected
getMappingTemplate(data
):MappingTemplate
Parameters
data
string
Returns
MappingTemplate
Call Signature
protected
getMappingTemplate(data
):undefined
Parameters
data
undefined
Returns
undefined
Call Signature
protected
getMappingTemplate(data
):undefined
|MappingTemplate
Parameters
data
undefined
| string
Returns
undefined
| MappingTemplate
getNoneDs()
protected
getNoneDs():BaseDataSource
Returns
BaseDataSource
getResolverProps()
protected
getResolverProps(resolver
):Omit
<BaseResolverProps
,"fieldName"
|"typeName"
>
Parameters
resolver
Returns
Omit
<BaseResolverProps
, "fieldName"
| "typeName"
>
getUnitResolverDataSource()
protected
getUnitResolverDataSource(resolver
):NonNullable
<undefined
|DataSource
>
Parameters
resolver
Returns
NonNullable
<undefined
| DataSource
>