-
Notifications
You must be signed in to change notification settings - Fork 4k
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(appsync): import existing graphql api #9254
Changes from 16 commits
1e0fea7
748b1c2
7b77d43
fc12e14
64b4f98
3bde2e9
48f7824
a68e1f6
b0ea1a2
d1e7c48
e136805
07dfea2
142c5f5
7e9b775
a44a9b8
d7678ba
c066ba9
ecc9145
4976bab
5243ef0
a668e13
5a15cf0
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 |
---|---|---|
@@ -0,0 +1,190 @@ | ||
import { ITable } from '@aws-cdk/aws-dynamodb'; | ||
import { IFunction } from '@aws-cdk/aws-lambda'; | ||
import { CfnResource, IResource, Resource } from '@aws-cdk/core'; | ||
import { DynamoDbDataSource, HttpDataSource, LambdaDataSource, NoneDataSource } from './data-source'; | ||
|
||
/** | ||
* Optional configuration for data sources | ||
*/ | ||
export interface DataSourceOptions { | ||
/** | ||
* The name of the data source | ||
* | ||
* @default - Automatically generated name '<DataSourceType>CDKDataSource' | ||
* i.e. (LambdaCDKDataSource) | ||
*/ | ||
readonly name?: string; | ||
|
||
/** | ||
* The description of the data source | ||
* | ||
* @default - No description | ||
*/ | ||
readonly description?: string; | ||
} | ||
|
||
/** | ||
* Interface for GraphQL | ||
*/ | ||
export interface IGraphQLApi extends IResource { | ||
|
||
/** | ||
* an unique AWS AppSync GraphQL API identifier | ||
* i.e. 'lxz775lwdrgcndgz3nurvac7oa' | ||
BryanPan342 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @attribute | ||
*/ | ||
readonly apiId: string; | ||
|
||
/** | ||
BryanPan342 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* the ARN of the API | ||
* | ||
* @attribute | ||
*/ | ||
readonly arn: string; | ||
|
||
/** | ||
* add a new dummy data source to this API. Useful for pipeline resolvers | ||
* and for backend changes that don't require a data source. | ||
* | ||
* @param options The optional configuration for this data source | ||
* @default name - 'NoneCDKDataSource' | ||
* description - No description | ||
*/ | ||
addNoneDataSource(options?: DataSourceOptions): NoneDataSource; | ||
|
||
/** | ||
* add a new DynamoDB data source to this API | ||
* | ||
* @param table The DynamoDB table backing this data source | ||
* @param options The optional configuration for this data source | ||
* @default name - 'DynamoDbCDKDataSource' | ||
* description - No description | ||
BryanPan342 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
addDynamoDbDataSource(table: ITable, options?: DataSourceOptions): DynamoDbDataSource; | ||
|
||
/** | ||
* add a new http data source to this API | ||
* | ||
* @param endpoint The http endpoint | ||
* @param options The optional configuration for this data source | ||
* @default name - 'HttpCDKDataSource' | ||
* description - No description | ||
*/ | ||
addHttpDataSource(endpoint: string, options?: DataSourceOptions): HttpDataSource; | ||
|
||
/** | ||
* add a new Lambda data source to this API | ||
* | ||
* @param lambdaFunction The Lambda function to call to interact with this data source | ||
* @param options The optional configuration for this data source | ||
* @default name - 'LambdaCDKDataSource' | ||
* description - No description | ||
*/ | ||
addLambdaDataSource(lambdaFunction: IFunction, options?: DataSourceOptions): LambdaDataSource; | ||
|
||
/** | ||
* Add schema dependency if not imported | ||
* | ||
* @param construct the dependee | ||
*/ | ||
addSchemaDependency(construct: CfnResource): boolean; | ||
} | ||
|
||
/** | ||
* Base Class for GraphQL API | ||
*/ | ||
export abstract class GraphQLApiBase extends Resource implements IGraphQLApi { | ||
|
||
/** | ||
* an unique AWS AppSync GraphQL API identifier | ||
* i.e. 'lxz775lwdrgcndgz3nurvac7oa' | ||
*/ | ||
public abstract readonly apiId: string; | ||
|
||
/** | ||
* the ARN of the API | ||
*/ | ||
public abstract readonly arn: 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. did we want to give this a specific prefix before the 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. if we change this here i feel like we need to change it for every where else.. including the GraphQLAPI.. i think this breaking change should happen in another pr |
||
|
||
/** | ||
* add a new none data source to this API. Useful for pipeline resolvers | ||
* and for backend changes that don't require a data source. | ||
* | ||
* @param options The optional configuration for this data source | ||
* @default name - 'NoneCDKDataSource' | ||
* description - No description | ||
*/ | ||
public addNoneDataSource(options?: DataSourceOptions): NoneDataSource { | ||
const name = options?.name ?? 'NoneCDKDataSource'; | ||
return new NoneDataSource(this, name, { | ||
api: this, | ||
name: name, | ||
description: options?.description, | ||
}); | ||
} | ||
|
||
/** | ||
* add a new DynamoDB data source to this API | ||
* | ||
* @param table The DynamoDB table backing this data source | ||
* @param options The optional configuration for this data source | ||
* @default name - 'DynamoDbCDKDataSource' | ||
* description - No description | ||
*/ | ||
public addDynamoDbDataSource(table: ITable, options?: DataSourceOptions): DynamoDbDataSource { | ||
const name = options?.name ?? 'DynamoDbCDKDataSource'; | ||
return new DynamoDbDataSource(this, name, { | ||
api: this, | ||
table, | ||
name, | ||
description: options?.description, | ||
}); | ||
} | ||
|
||
/** | ||
* add a new http data source to this API | ||
* | ||
* @param endpoint The http endpoint | ||
* @param options The optional configuration for this data source | ||
* @default name - 'HttpCDKDataSource' | ||
* description - No description | ||
*/ | ||
public addHttpDataSource(endpoint: string, options?: DataSourceOptions): HttpDataSource { | ||
const name = options?.name ?? 'HttpCDKDataSource'; | ||
return new HttpDataSource(this, name, { | ||
api: this, | ||
endpoint, | ||
name, | ||
description: options?.description, | ||
}); | ||
} | ||
|
||
/** | ||
* add a new Lambda data source to this API | ||
* | ||
* @param lambdaFunction The Lambda function to call to interact with this data source | ||
* @param options The optional configuration for this data source | ||
* @default name - 'LambdaCDKDataSource' | ||
* description - No description | ||
*/ | ||
public addLambdaDataSource(lambdaFunction: IFunction, options?: DataSourceOptions): LambdaDataSource { | ||
const name = options?.name ?? 'LambdaCDKDataSource'; | ||
return new LambdaDataSource(this, name, { | ||
api: this, | ||
lambdaFunction, | ||
name, | ||
description: options?.description, | ||
}); | ||
} | ||
|
||
/** | ||
* Add schema dependency if not imported | ||
* | ||
* @param construct the dependee | ||
*/ | ||
public addSchemaDependency(construct: CfnResource): boolean { | ||
construct; | ||
return false; | ||
} | ||
} |
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.
and change everywhere else