Skip to content

[aws-appsync] code-first implementation of query definition #9308

@BryanPan342

Description

@BryanPan342

Allow query definition for schema.

Use Case

Would allow for definition of query 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.addQuery( 'getExamples', {
  type: ScalarType.list.custom(example),
  resolve: [{
    dataSource: exampleDS,
    request: MappingTemplate.dynamoDbScanTable(),
    response: MappingTemplate.dynamoDbResultList(),
  }],
});

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

Other

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