Skip to content
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

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

Closed
BryanPan342 opened this issue Jul 30, 2020 · 0 comments · Fixed by #10078
Closed

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

BryanPan342 opened this issue Jul 30, 2020 · 0 comments · Fixed by #10078
Assignees
Labels
@aws-cdk/aws-appsync Related to AWS AppSync effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p2

Comments

@BryanPan342
Copy link
Contributor

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

@BryanPan342 BryanPan342 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 30, 2020
@BryanPan342 BryanPan342 self-assigned this Jul 30, 2020
@BryanPan342 BryanPan342 changed the title [subscription] code-first implementation for schema definition [aws-appsync] code-first implementation for subscription definition Jul 30, 2020
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Jul 30, 2020
@BryanPan342 BryanPan342 added effort/medium Medium work item – several days of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 30, 2020
@BryanPan342 BryanPan342 added the in-progress This issue is being actively worked on. label Aug 31, 2020
@mergify mergify bot closed this as completed in #10078 Sep 11, 2020
mergify bot pushed a commit that referenced this issue Sep 11, 2020
…neration (#10078)

Implemented an `addSubscription` function for the `appsync.Schema` class to make easy schema generation. 

```ts
api.addSubscription('addedFilm', new appsync.ResolvableField({
  returnType: film.attribute(),
  args: { id: appsync.GraphqlType.id({ isRequired: true }) },
  directive: [appsync.Directive.subscribe('addFilm')],
}));
```
Fixes: #9345 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants