Instantialize AppSync
It's time to create an AppSync CDK/SST construct, if not yet created.
- Serverless Stack Toolkit
- AWS Cloud Development Kit
stacks/MyStack.ts
import { StackContext, AppSyncApi } from "@serverless-stack/resources";
export function MyStack({ stack }: StackContext) {
const api = new AppSyncApi(stack, "api", {
schema: "graphql/index.graphql"
});
stack.addOutputs({
GraphQlApiEndpoint: api.url,
});
}
lib/app-stack.ts
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { GraphqlApi } from '@aws-cdk/aws-appsync-alpha';
export class AppStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
// The code that defines your stack goes here
const api = new GraphqlApi(this, "api", {
name: "time-pingpong-api"
});
}
}