Skip to content

Commit

Permalink
chore(appsync): introduce breaking changes to api for consistency (aw…
Browse files Browse the repository at this point in the history
…s#10101)

Change all instances of `GraphQLApi`/`GraphQlApi` to be `GraphqlApi`/`graphqlApi`. This was done to make the snake casing for python users feel more natural.

**Before**

```ts
appsync.GraphQLApi(...)
appsync.GraphQLApiProps
appsync.GraphQLApi.graphQlUrl
```

**After**

```ts
appsync.GraphqlApi(...)
appsync.GraphqlApiProps
appsync.GraphqlApi.graphqlUrl
```

**BREAKING CHANGES**: Change all instances of `GraphQLApi` or `graphQLApi` or `graphQlApi` to be `graphqlApi`/`GraphqlApi`.
- **appsync**: change `GraphQLApi` to `GraphqlApi` (all instances of `xxxQL` or `xxxQl` to `xxxql`

Fixes aws#9367

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
BryanPan342 authored Sep 1, 2020
1 parent 05f5e62 commit 9edbec9
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 108 deletions.
20 changes: 10 additions & 10 deletions packages/@aws-cdk/aws-appsync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ CDK stack file `app-stack.ts`:
import * as appsync from '@aws-cdk/aws-appsync';
import * as db from '@aws-cdk/aws-dynamodb';

const api = new appsync.GraphQLApi(stack, 'Api', {
const api = new appsync.GraphqlApi(stack, 'Api', {
name: 'demo',
schema: appsync.Schema.fromAsset(join(__dirname, 'schema.graphql')),
authorizationConfig: {
Expand Down Expand Up @@ -94,7 +94,7 @@ When declaring your GraphQL Api, CDK defaults to a code-first approach if the
`schema` property is not configured.

```ts
const api = new appsync.GraphQLApi(stack, 'api', { name: 'myApi' });
const api = new appsync.GraphqlApi(stack, 'api', { name: 'myApi' });
```

CDK will declare a `Schema` class that will give your Api access functions to
Expand All @@ -108,7 +108,7 @@ const schema = new appsync.Schema();
schema.addObjectType('demo', {
definition: { id: appsync.GraphqlType.id() },
});
const api = new appsync.GraphQLApi(stack, 'api', {
const api = new appsync.GraphqlApi(stack, 'api', {
name: 'myApi',
schema
});
Expand All @@ -122,7 +122,7 @@ You can define your GraphQL Schema from a file on disk. For convenience, use
the `appsync.Schema.fromAsset` to specify the file representing your schema.

```ts
const api = appsync.GraphQLApi(stack, 'api', {
const api = appsync.GraphqlApi(stack, 'api', {
name: 'myApi',
schema: appsync.Schema.fromAsset(join(__dirname, 'schema.graphl')),
});
Expand All @@ -132,10 +132,10 @@ const api = appsync.GraphQLApi(stack, 'api', {

Any GraphQL Api that has been created outside the stack can be imported from
another stack into your CDK app. Utilizing the `fromXxx` function, you have
the ability to add data sources and resolvers through a `IGraphQLApi` interface.
the ability to add data sources and resolvers through a `IGraphqlApi` interface.

```ts
const importedApi = appsync.GraphQLApi.fromGraphQLApiAttributes(stack, 'IApi', {
const importedApi = appsync.GraphqlApi.fromGraphqlApiAttributes(stack, 'IApi', {
graphqlApiId: api.apiId,
graphqlArn: api.arn,
});
Expand Down Expand Up @@ -191,7 +191,7 @@ Use the `grant` function for more granular authorization.
const role = new iam.Role(stack, 'Role', {
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
});
const api = new appsync.GraphQLApi(stack, 'API', {
const api = new appsync.GraphqlApi(stack, 'API', {
definition
});

Expand Down Expand Up @@ -323,7 +323,7 @@ to generate our schema.
import * as appsync from '@aws-cdk/aws-appsync';
import * as schema from './object-types';

const api = new appsync.GraphQLApi(stack, 'Api', {
const api = new appsync.GraphqlApi(stack, 'Api', {
name: 'demo',
});

Expand Down Expand Up @@ -497,7 +497,7 @@ You can create Object Types in three ways:

1. Object Types can be created ***externally***.
```ts
const api = new appsync.GraphQLApi(stack, 'Api', {
const api = new appsync.GraphqlApi(stack, 'Api', {
name: 'demo',
});
const demo = new appsync.ObjectType('Demo', {
Expand Down Expand Up @@ -552,7 +552,7 @@ You can create Object Types in three ways:

3. Object Types can be created ***internally*** within the GraphQL API.
```ts
const api = new appsync.GraphQLApi(stack, 'Api', {
const api = new appsync.GraphqlApi(stack, 'Api', {
name: 'demo',
});
api.addType('Demo', {
Expand Down
14 changes: 7 additions & 7 deletions packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export interface LogConfig {
/**
* Properties for an AppSync GraphQL API
*/
export interface GraphQLApiProps {
export interface GraphqlApiProps {
/**
* the name of the GraphQL API
*/
Expand Down Expand Up @@ -293,7 +293,7 @@ export class IamResource {
*
* @param api The GraphQL API to give permissions
*/
public resourceArns(api: GraphQLApi): string[] {
public resourceArns(api: GraphqlApi): string[] {
return this.arns.map((arn) => Stack.of(api).formatArn({
service: 'appsync',
resource: `apis/${api.apiId}`,
Expand Down Expand Up @@ -325,7 +325,7 @@ export interface GraphqlApiAttributes {
*
* @resource AWS::AppSync::GraphQLApi
*/
export class GraphQLApi extends GraphqlApiBase {
export class GraphqlApi extends GraphqlApiBase {
/**
* Import a GraphQL API through this function
*
Expand Down Expand Up @@ -362,9 +362,9 @@ export class GraphQLApi extends GraphqlApiBase {
/**
* the URL of the endpoint created by AppSync
*
* @attribute
* @attribute GraphQlUrl
*/
public readonly graphQlUrl: string;
public readonly graphqlUrl: string;

/**
* the name of the API
Expand All @@ -387,7 +387,7 @@ export class GraphQLApi extends GraphqlApiBase {
private api: CfnGraphQLApi;
private apiKeyResource?: CfnApiKey;

constructor(scope: Construct, id: string, props: GraphQLApiProps) {
constructor(scope: Construct, id: string, props: GraphqlApiProps) {
super(scope, id);

const defaultMode = props.authorizationConfig?.defaultAuthorization ??
Expand All @@ -409,7 +409,7 @@ export class GraphQLApi extends GraphqlApiBase {

this.apiId = this.api.attrApiId;
this.arn = this.api.attrArn;
this.graphQlUrl = this.api.attrGraphQlUrl;
this.graphqlUrl = this.api.attrGraphQlUrl;
this.name = this.api.name;
this.schema = props.schema ?? new Schema();
this.schemaResource = this.schema.bind(this);
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-appsync/lib/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFileSync } from 'fs';
import { Lazy } from '@aws-cdk/core';
import { CfnGraphQLSchema } from './appsync.generated';
import { GraphQLApi } from './graphqlapi';
import { GraphqlApi } from './graphqlapi';
import { SchemaMode, shapeAddition } from './private';
import { IIntermediateType } from './schema-base';
import { ResolvableField } from './schema-field';
Expand Down Expand Up @@ -72,7 +72,7 @@ export class Schema {
*
* @param api The binding GraphQL Api
*/
public bind(api: GraphQLApi): CfnGraphQLSchema {
public bind(api: GraphqlApi): CfnGraphQLSchema {
if (!this.schema) {
this.schema = new CfnGraphQLSchema(api, 'Schema', {
apiId: api.apiId,
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
"no-unused-type:@aws-cdk/aws-appsync.ApiKeyConfig",
"no-unused-type:@aws-cdk/aws-appsync.UserPoolConfig",
"no-unused-type:@aws-cdk/aws-appsync.UserPoolDefaultAction",
"props-physical-name:@aws-cdk/aws-appsync.GraphQLApiProps",
"from-method:@aws-cdk/aws-appsync.GraphQLApi"
"props-physical-name:@aws-cdk/aws-appsync.GraphqlApiProps",
"from-method:@aws-cdk/aws-appsync.GraphqlApi"
]
},
"stability": "experimental",
Expand Down
46 changes: 23 additions & 23 deletions packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beforeEach(() => {
describe('AppSync API Key Authorization', () => {
test('AppSync creates default api key', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
});
Expand All @@ -24,7 +24,7 @@ describe('AppSync API Key Authorization', () => {

test('AppSync creates api key from additionalAuthorizationModes', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -41,7 +41,7 @@ describe('AppSync API Key Authorization', () => {

test('AppSync does not create unspecified api key from additionalAuthorizationModes', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -55,7 +55,7 @@ describe('AppSync API Key Authorization', () => {

test('appsync does not create unspecified api key with empty additionalAuthorizationModes', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -70,7 +70,7 @@ describe('AppSync API Key Authorization', () => {

test('appsync creates configured api key with additionalAuthorizationModes', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -90,7 +90,7 @@ describe('AppSync API Key Authorization', () => {

test('appsync creates configured api key with additionalAuthorizationModes (not as first element)', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -117,7 +117,7 @@ describe('AppSync API Key Authorization', () => {
test('appsync fails when empty default and API_KEY in additional', () => {
// THEN
expect(() => {
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -132,7 +132,7 @@ describe('AppSync API Key Authorization', () => {
test('appsync fails when multiple API_KEY auth modes', () => {
// THEN
expect(() => {
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -148,7 +148,7 @@ describe('AppSync API Key Authorization', () => {
test('appsync fails when multiple API_KEY auth modes in additionalXxx', () => {
// THEN
expect(() => {
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -166,7 +166,7 @@ describe('AppSync API Key Authorization', () => {
describe('AppSync IAM Authorization', () => {
test('Iam authorization configurable in default authorization', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -182,7 +182,7 @@ describe('AppSync IAM Authorization', () => {

test('Iam authorization configurable in additional authorization', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -199,7 +199,7 @@ describe('AppSync IAM Authorization', () => {
test('appsync fails when multiple iam auth modes', () => {
// THEN
expect(() => {
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -213,7 +213,7 @@ describe('AppSync IAM Authorization', () => {
test('appsync fails when multiple IAM auth modes in additionalXxx', () => {
// THEN
expect(() => {
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -234,7 +234,7 @@ describe('AppSync User Pool Authorization', () => {
});
test('User Pool authorization configurable in default authorization has default configuration', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -258,7 +258,7 @@ describe('AppSync User Pool Authorization', () => {

test('User Pool authorization configurable in default authorization', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('AppSync User Pool Authorization', () => {

test('User Pool authorization configurable in additional authorization has default configuration', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -312,7 +312,7 @@ describe('AppSync User Pool Authorization', () => {

test('User Pool property defaultAction does not configure when in additional auth', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand Down Expand Up @@ -342,7 +342,7 @@ describe('AppSync User Pool Authorization', () => {

test('User Pool property defaultAction does not configure when in additional auth', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand Down Expand Up @@ -399,7 +399,7 @@ describe('AppSync User Pool Authorization', () => {
describe('AppSync OIDC Authorization', () => {
test('OIDC authorization configurable in default authorization has default configuration', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -421,7 +421,7 @@ describe('AppSync OIDC Authorization', () => {

test('User Pool authorization configurable in default authorization', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand Down Expand Up @@ -451,7 +451,7 @@ describe('AppSync OIDC Authorization', () => {

test('OIDC authorization configurable in additional authorization has default configuration', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand All @@ -475,7 +475,7 @@ describe('AppSync OIDC Authorization', () => {

test('User Pool authorization configurable in additional authorization', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand Down Expand Up @@ -507,7 +507,7 @@ describe('AppSync OIDC Authorization', () => {

test('User Pool authorization configurable in with multiple authorization', () => {
// WHEN
new appsync.GraphQLApi(stack, 'api', {
new appsync.GraphqlApi(stack, 'api', {
name: 'api',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
authorizationConfig: {
Expand Down
Loading

0 comments on commit 9edbec9

Please sign in to comment.