Skip to content

Instantly share code, notes, and snippets.

@mmccall10
Last active October 18, 2021 14:32
Show Gist options
  • Save mmccall10/c4070e5df1befd95b69e78d98005f099 to your computer and use it in GitHub Desktop.
Save mmccall10/c4070e5df1befd95b69e78d98005f099 to your computer and use it in GitHub Desktop.

Revisions

  1. mmccall10 revised this gist Oct 18, 2021. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion GraphqlApiStack.ts
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,6 @@ export default class GraphqlApiStack extends Stack {
    super(scope, id, props)

    this.api = new GraphqlApi(this, 'GraphqlApi', {
    deltaSyncTable: this.changelogTable,
    name: 'GraphqlApi',
    schema: Schema.fromAsset('graphql/schema.graphql'),
    authorizationConfig: {
  2. mmccall10 created this gist Oct 18, 2021.
    14 changes: 14 additions & 0 deletions EnforceAppSyncResolverNaming.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import { CfnResolver } from '@aws-cdk/aws-appsync'
    import { IConstruct } from '@aws-cdk/core'

    interface IAspect {
    visit: (node: IConstruct) => void
    }

    class EnforceAppSyncResolverNaming implements IAspect {
    visit (node: IConstruct): void {
    if (node instanceof CfnResolver) node.overrideLogicalId(`${node.typeName}${node.fieldName}Resolver`)
    }
    }

    export { EnforceAppSyncResolverNaming }
    20 changes: 20 additions & 0 deletions GraphqlApiStack.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    export default class GraphqlApiStack extends Stack {
    api: GraphqlApi

    constructor (scope: sst.App, id: string, props: GraphqlStackProps) {
    super(scope, id, props)

    this.api = new GraphqlApi(this, 'GraphqlApi', {
    deltaSyncTable: this.changelogTable,
    name: 'GraphqlApi',
    schema: Schema.fromAsset('graphql/schema.graphql'),
    authorizationConfig: {
    defaultAuthorization: {
    authorizationType: AuthorizationType.API_KEY
    }
    }
    })

    Aspects.of(this.api).add(new EnforceAppSyncResolverNaming())
    }
    }