Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

Make createServer accept a serverless instance #92

Merged
merged 2 commits into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions packages/appsync-emulator-serverless/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ const createSchema = async ({
pubsub,
dynamodb,
} = {}) => {
const serverlessDirectory =
typeof serverless === 'string'
? path.dirname(serverless)
: findServerlessPath();
const { config: serverlessConfig } = await loadServerlessConfig(
serverlessDirectory,
);
let serverlessConfig = {};
let serverlessDirectory;
if (typeof serverless === 'object') {
serverlessConfig = serverless.service;
serverlessDirectory = serverless.config.servicePath;
} else {
serverlessDirectory =
typeof serverless === 'string'
? path.dirname(serverless)
: findServerlessPath();
const config = await loadServerlessConfig(serverlessDirectory);
serverlessConfig = config.config;
}

// eslint-disable-next-line
schemaPath = schemaPath || path.join(serverlessDirectory, 'schema.graphql');
Expand Down