In AWS AppSync, I have a Lambda resolver. The resolver handles multiple queries e.g. getUser, getUsers, getClient, etc. How can the Lambda function get the query return type defined in the AppSync GraphQL schema?
The return types are defined in the AppSync GraphQL schema query section:
type Query {
getClient(_id: ID!): Client
getUser(_id: ID!): User
getUsers(): UserConnection
}
The lambda event variables contain the following for the query getUser:
"info": {
"parentTypeName": "Query",
"selectionSetList": [
"_id",
"email"
],
"selectionSetGraphQL": "{\n _id\n email\n}",
"fieldName": "getUser",
"variables": {
"id": "5c42109b2eb8ed82c8862532"
}
},
"stash": {}
Using the AWS SDK I can call the AppSync API method getIntrospectionSchema but it does not return any queries or mutations -- only an array of all types.
I can also call the getResolver method but it does not return the field return type.
var appsync = new AWS.AppSync();
var params = {
apiId: 'xxxxx',
fieldName: 'getUser',
typeName: 'Query',
};
const data = await appsync.getResolver(params).promise();
Response:
dataSourceName:'myLambdaDatasource'
fieldName:'getUser'
kind:'UNIT'
requestMappingTemplate:null
resolverArn:'arn:.../types/Query/resolvers/getUser'
responseMappingTemplate:null
typeName:'Query'