Skip to content

[aws-appsync] code-first implementation for subscription definition  #9345

@BryanPan342

Description

@BryanPan342

Allow subscription definition for schema.

Use Case

Would allow for definition of subscription type fields alongside resolvers for a code-first approach.

Proposed Solution

const api = new GraphQLApi(stack, 'ExampleApi', {
  name: 'example',
  schemaDefinition: SCHEMA.CODE,
  ...
}

const example = api.addType('Example', {
  definition: {
    ScalarType.int('id').required(),
    ScalarType.string('content').required(), 
  },
  authorization: AUTH.AWS_IAM,
});

api.addSubscription( 'addExample', {
  type: ObjectType.custom(example),
  args: {
    version: {
      type: type.string(),
      required: true,
    },
  },
  mutations: [
    addExample,
  ],
});

Subscription is defined through a code-first approach and resolvers are mapped inline.

Other

Subscriptions in AWS AppSync are invoked as a response to a mutation. You configure this with a Subscription type and @aws_subscribe() directive in the schema to denote which mutations invoke one or more subscriptions. For more information about configuring subscriptions, see here.

Tracked by: #9305


This is a 🚀 Feature Request

Metadata

Metadata

Labels

@aws-cdk/aws-appsyncRelated to AWS AppSynceffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.in-progressThis issue is being actively worked on.p2

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions