@adobe-apimesh/mesh-builder
v2.4.0-alpha.1
Published
Package with mesh artifacts building and compiling logic
Keywords
Readme
Mesh Builder
Package with mesh artifacts building and compiling logic
Exports
validateMesh
validateMesh(meshConfig: MeshConfig) => Promise
Validate Mesh function takes the meshConfig as argument and validates if the mesh confines with the CLI rules. Upon a successful validation the function resolves the returned promise. If validation fails, all reasons for invalidation will be thrown in the rejected promise.
buildMesh
buildMesh(meshId: string, meshConfig: MeshConfig) => Promise<boolean | undefined>
Build Mesh function takes the meshId and meshConfig as arguments and builds the mesh artifacts under the mesh-artifact folder in the current working directory under the meshId sub directory.
Upon a successful build, buildMesh returns a Promise that resolves to true and false for a failure. buildMesh will throw MeshBuildError if there is a bulid error.
compileMesh
compileMesh(meshId: string) => Promise<string[]>
Compile Mesh function takes the meshId to find the built TypeScript mesh artifacts under the mesh-artifact folder and compiles them to JavaScript using the typescript package. It returns a Promise of JavaScript file paths that have been compiled and written to file system.
normalizeMeshConfig
normalizeMeshConfig(meshConfig: MeshConfig, basePath?: string) => Promise
Normalize Mesh Config function takes the meshConfig and normalizes additionalTypeDefs.
If additionalTypeDefs contains .graphql/.gql paths, it will resolve their contents (including via meshConfig.files, disk, or relative to basePath when provided), keeps additionalTypeDefs as an array of strings, and removes any GraphQL file entries from meshConfig.files.
import meshBuilder from "@multitenant-graphql/mesh-builder";
const normalized = await meshBuilder.normalizeMeshConfig(meshConfig);
// or
const normalized = await meshBuilder.normalizeMeshConfig(meshConfig, "/abs/path/to/.meshrc.json");Types
validateMesh(meshConfig: MeshConfig) => Promise<boolean>
buildMesh(meshId: string, meshConfig: MeshConfig) => Promise<boolean | undefined>
compileMesh(meshId: string) => Promise<string[]>
normalizeMeshConfig(meshConfig: MeshConfig, basePath?: string) => Promise<MeshConfig>
type MeshBuildError {
name: string;
stack?: string;
cause?: unknown;
requestId?: string;
}