GraphQL Resolver
Resource Overview
A GraphQL Resolver handles your GraphQL requests and fetches information from your application's data sources. GraphQL Resolvers can be attached and configured only after a correctly formatted schema has been supplied. Each resolver requires resolver mapping templates used to translate requests and responses between your GraphQL API and its data source.
There are two types of Resolver Mapping Templates and they both are written in the Apache Velocity Template Language (.vm
), which take in a request and outputs a JSON document containing the request or response instructions for your resolver.
Request Mapping Templates
Interpret client requests and translate them into data-handling instructions your data source can understand.
Response Mapping Templates
Interpret responses from your data source and translate them into GraphQL responses.
GraphQL Resolver resources are not available in the Add Resource side panel. You must first define a GraphQL schema and attach the desired resolver to your GraphQL API before configuring it. See GraphQL API for more info.
Event Subscription
Event subscription wires (solid line) visualize and configure event subscription integrations between two resources.
The following resources can be subscribed to a GraphQL Resolver:
- Function
- Table
- HTTP Proxy Endpoint
Configurable Properties
Save Request Mapping File
Enable this feature to save your Request Mapping Template to a .vm
file then define a path relative to your Git repository.
Request Template File Location
Specify the location of your Request Template Mapping file as it relates to your stack's git repository.
Request Mapping Template
Written in Apache Velocity Template Language and translates your GraphQL query into instructions for your resolver to follow when you want to retrieve data. GraphQL API resources currently support Function, Table, and HTTP Proxy Endpoint resources as your application's data source. Detailed reference guides for creating your Request Mapping Templates can be found for each supported data source below.
Save Response Mapping File
Enable this feature to save your Response Mapping Template to a .vm
file then define a path relative to your Git repository.
Response Mapping File Location
Specify the location of your Response Template Mapping file as it relates to your stack's git repository.
Response Mapping Template
Written in Apache Velocity Template Language and describes how to handle a response from your data source. In most cases, the response mapping template is the context.result
wrapped in the $utils.toJson
utility function to pass a JSON object back to the client. However, additional logic can be input in this template for more fine-grained control of the response your GraphQL API returns.
IAM Permissions
When connected by a service discovery wire (dashed wire), a Function or Docker Task will add the following IAM policy to its role and gain permission to access this resource.
No Permissions Added
Environment Variables
When connected by a service discovery wire (dashed wire), a Function or Docker Task will automatically populate and reference the following environment variables in order to interact with this resource.
No Available Environment Variables
Metrics & Logs
Double clicking a resource while viewing your stack's current deployment gives you access to your pre-configured resource properties, and links to the following metrics and logs.
- Logs
Related AWS Documentation
AWS Documentation: AWS::AppSync::Resolver