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 of mutation definition #9310

Closed
BryanPan342 opened this issue Jul 28, 2020 · 0 comments · Fixed by #9992
Closed

[aws-appsync] code-first implementation of mutation definition #9310

BryanPan342 opened this issue Jul 28, 2020 · 0 comments · Fixed by #9992
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 mutation definition for schema.

Use Case

Would allow for definition of mutation 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.addMutation( 'addExample', {
  type: ObjectType.custom(example),
  args: {
    version: {
      type: type.string(),
      required: true,
    },
  },
  resolve: [{
    dataSource: exampleDS,
    request: MappingTemplate.dynamoDbPutItem(PrimaryKey.partition('id').auto(), Values.projecting('example')),
    response: MappingTemplate.dynamoDbResultItem(),
  }],
  authorization: AUTH.AWS_IAM,
});

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

Other

Tracked by: #9305


This is a 🚀 Feature Request

@BryanPan342 BryanPan342 added p2 feature-request A feature should be added or improved. effort/medium Medium work item – several days of effort labels Jul 28, 2020
@BryanPan342 BryanPan342 self-assigned this Jul 28, 2020
@BryanPan342 BryanPan342 changed the title [module] [aws-appsync] code-first implementation of subscription definition Jul 28, 2020
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Jul 28, 2020
@BryanPan342 BryanPan342 changed the title [aws-appsync] code-first implementation of subscription definition [aws-appsync] code-first implementation of mutation definition Jul 28, 2020
@BryanPan342 BryanPan342 added the in-progress This issue is being actively worked on. label Aug 28, 2020
@mergify mergify bot closed this as completed in #9992 Aug 29, 2020
mergify bot pushed a commit that referenced this issue Aug 29, 2020
…roach (#9992)

Implemented methods in `appsync.Schema` to easily generate query/mutation fields, or bind an existing `ObjectType` as the top level query/mutation type.

Fixes: #9308 
Fixes: #9310 

----

*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