How to use amplify-appsync-simulator - 3 common examples

To help you get started, we’ve selected a few amplify-appsync-simulator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-cli / packages / amplify-util-mock / src / __e2e__ / utils / index.ts View on Github external
export async function runAppSyncSimulator(config, port?: number, wsPort?: number) {
  const appsyncSimulator = new AmplifyAppSyncSimulator({ port, wsPort });
  await appsyncSimulator.start();
  await appsyncSimulator.init(config);
  return appsyncSimulator;
}
github aws-amplify / amplify-cli / packages / amplify-util-mock / src / api / api.ts View on Github external
async start(context, port: number = 20002, wsPort: number = 20003) {
    try {
      addCleanupTask(context, async context => {
        await this.stop(context);
      });
      this.projectRoot = context.amplify.getEnvInfo().projectPath;
      this.configOverrideManager = ConfigOverrideManager.getInstance(context);
      this.apiName = await this.getAppSyncAPI(context);
      this.ddbClient = await this.startDynamoDBLocalServer(context);
      const resolverDirectory = await this.getResolverTemplateDirectory(context);
      this.resolverOverrideManager = new ResolverOverrides(resolverDirectory);
      this.appSyncSimulator = new AmplifyAppSyncSimulator({
        port,
        wsPort,
      });
      await this.appSyncSimulator.start();
      await this.resolverOverrideManager.start();
      await this.watch(context);
      const appSyncConfig: AmplifyAppSyncSimulatorConfig = await this.runTransformer(context);
      this.appSyncSimulator.init(appSyncConfig);

      await this.generateTestFrontendExports(context);
      await this.generateCode(context);

      context.print.info(`AppSync Mock endpoint is running at ${this.appSyncSimulator.url}`);
    } catch (e) {
      context.print.error(`Failed to start API Mock endpoint ${e}`);
    }
github aws-amplify / amplify-cli / packages / amplify-util-mock / src / CFNParser / appsync-resource-processor.ts View on Github external
resources: {},
    exports: {},
  };
  const processedResources: AmplifyAppSyncSimulatorConfig = {
    schema: {
      content: '',
    },
    resolvers: [],
    functions: [],
    dataSources: [],
    mappingTemplates: [],
    tables: [],
    appSync: {
      name: '',
      defaultAuthenticationType: {
        authenticationType: AmplifyAppSyncSimulatorAuthenticationType.API_KEY,
      },
      apiKey: null,
      additionalAuthenticationProviders: [],
    },
  };
  Object.entries(resources).forEach(entry => {
    const [resourceName, resource] = entry;
    const { Type: resourceType } = resource as any;
    if (Object.keys(resourceProcessorMapping).includes(resourceType)) {
      const result = resourceProcessorMapping[resourceType](resourceName, resource, cfnContext, transformResult);
      cfnContext.resources[resourceName] = result;

      switch (resourceType) {
        case 'AWS::AppSync::DataSource':
          processedResources.dataSources.push(result);
          break;

amplify-appsync-simulator

An AppSync Simulator to test AppSync API.

Apache-2.0
Latest version published 2 years ago

Package Health Score

72 / 100
Full package analysis