-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support apiId(Multiple cloudformation stacks) #597
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -65,6 +65,7 @@ import { | |||||
ListCertificatesResponse, | ||||||
} from 'aws-sdk/clients/acm'; | ||||||
import terminalLink from 'terminal-link'; | ||||||
import { AppSyncConfig } from './types/plugin'; | ||||||
|
||||||
const CONSOLE_BASE_URL = 'https://console.aws.amazon.com'; | ||||||
|
||||||
|
@@ -86,6 +87,7 @@ class ServerlessAppsyncPlugin { | |||||
public readonly configurationVariablesSources?: VariablesSourcesDefinition; | ||||||
private api?: Api; | ||||||
private naming?: Naming; | ||||||
private config?: AppSyncConfig; | ||||||
|
||||||
constructor( | ||||||
public serverless: Serverless, | ||||||
|
@@ -347,6 +349,11 @@ class ServerlessAppsyncPlugin { | |||||
async getApiId() { | ||||||
this.loadConfig(); | ||||||
|
||||||
if (this.config?.apiId) { | ||||||
return this.config.apiId; | ||||||
} | ||||||
|
||||||
|
||||||
if (!this.naming) { | ||||||
throw new this.serverless.classes.Error( | ||||||
'Could not find the naming service. This should not happen.', | ||||||
|
@@ -377,6 +384,10 @@ class ServerlessAppsyncPlugin { | |||||
async gatherData() { | ||||||
const apiId = await this.getApiId(); | ||||||
|
||||||
if (typeof apiId !== 'string') { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
if for some reason, |
||||||
return; | ||||||
} | ||||||
|
||||||
const { graphqlApi } = await this.provider.request< | ||||||
GetGraphqlApiRequest, | ||||||
GetGraphqlApiResponse | ||||||
|
@@ -410,6 +421,10 @@ class ServerlessAppsyncPlugin { | |||||
async getIntrospection() { | ||||||
const apiId = await this.getApiId(); | ||||||
|
||||||
if (typeof apiId !== 'string') { | ||||||
return; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just returning is probably not good enough. In fact I would probably not allow calling any of these commands (assoc domain, etc) from a "child" service stack.
|
||||||
} | ||||||
|
||||||
const { schema } = await this.provider.request< | ||||||
GetIntrospectionSchemaRequest, | ||||||
GetIntrospectionSchemaResponse | ||||||
|
@@ -673,10 +688,16 @@ class ServerlessAppsyncPlugin { | |||||
} | ||||||
|
||||||
async assocDomain() { | ||||||
const domain = this.getDomain(); | ||||||
const apiId = await this.getApiId(); | ||||||
|
||||||
if (typeof apiId !== 'string') { | ||||||
return; | ||||||
} | ||||||
|
||||||
const domain = this.getDomain(); | ||||||
const assoc = await this.getApiAssocStatus(domain.name); | ||||||
|
||||||
|
||||||
if (assoc?.associationStatus !== 'NOT_FOUND' && assoc?.apiId !== apiId) { | ||||||
log.warning( | ||||||
`The domain ${domain.name} is currently associated to another API (${assoc?.apiId})`, | ||||||
|
@@ -957,9 +978,9 @@ class ServerlessAppsyncPlugin { | |||||
throw error; | ||||||
} | ||||||
} | ||||||
const config = getAppSyncConfig(appSync); | ||||||
this.config = getAppSyncConfig(appSync); | ||||||
this.naming = new Naming(appSync.name); | ||||||
this.api = new Api(config, this); | ||||||
this.api = new Api(this.config, this); | ||||||
} | ||||||
|
||||||
validateSchemas() { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section is confusing and probably not necessary.
Instead, we should add clear guidelines on how and why you should use the
apiId
parameters.A bit like described here for API Gateway.