Class: Reader
Resolver and function reader.
import { Reader } from 'aws-appsync-butler';
const reader = new Reader();
reader.readTypes(); // ['Query', 'Mutation', 'Post']
reader.readFields('Query'); // ['getPost', 'getAuthor']
const resolver = reader.readResolver('Query', 'getPost');
reader.readFunctions(); // ['getPostById', 'getAuthorByPostId']
const func = reader.readFunction('getPostById');
Hierarchy
Readerโณ
Parser
Constructors
constructor
โข new Reader(optionsOrRoot?)
Parameters
| Name | Type | Description |
|---|---|---|
optionsOrRoot | string | ReaderOptions | Path to VTL directory or reading directives |
Methods
readFunctions
โธ readFunctions(): string[]
Reads the on-disk function directory names. Essentially, the
first-level subdirectories of functions are read.
vtl
โโโ functions
โ โโโ GetPostById
โ โโโ request.vtl
โ โโโ response.vtl
โโโ resolvers
reader.readFunctions(); // ['GetPostById']
Returns
string[]
A list of function names
readTypes
โธ readTypes(): string[]
Reads the on-disk GraphQL type names. Essentially, the
first-level subdirectories of resolvers are read.
vtl
โโโ functions
โโโ resolvers
โโโ Mutation
โโโ Query
โโโ Post
reader.readTypes(); // ['Mutation', 'Query', 'Post']
Returns
string[]
A list of GraphQL types
readFields
โธ readFields(typeName): string[]
Reads the on-disk GraphQL field names. Essentially, the
second-level subdirectories of resolvers are read.
vtl
โโโ functions
โโโ resolvers
โโโ Mutation
โโโ Query
โโโ getPost
โโโ request.vtl
โโโ response.vtl
reader.readFields('Query'); // ['getPost']
Parameters
| Name | Type | Description |
|---|---|---|
typeName | string | GraphQL type name |
Returns
string[]
A list of GraphQL fields
readResolver
โธ readResolver(typeName, fieldName): ResolverInfo
Reads a GraphQL field resolver from disk.
Parameters
| Name | Type | Description |
|---|---|---|
typeName | string | GraphQL type name |
fieldName | string | GraphQL field name |
Returns
Unit or Pipeline Resolver information
readFunction
โธ readFunction(functionName): FunctionInfo
Reads an AWS AppSync Function from disk.
Parameters
| Name | Type | Description |
|---|---|---|
functionName | string | Function name |
Returns
Function information