in src/pipelineResources.js [681:721]
async function attachResolverToSchemaField (client, apiId, functionId, typeName, fieldName) {
// attach resolvers to schema
const startMsg = 'Attaching resolver to schema type ' + yellow(typeName) + ' field ' + yellow(fieldName) + ' ...';
startSpinner(startMsg);
loggerDebug(startMsg);
const input = {
apiId: apiId,
typeName: typeName,
fieldName: fieldName,
kind: "PIPELINE",
pipelineConfig: {
functions: [
functionId
],
},
runtime: {
name: "APPSYNC_JS",
runtimeVersion: "1.0.0",
},
code:
`
import {util} from '@aws-appsync/utils';
export function request(ctx) {
return {};
}
export function response(ctx) {
return ctx.prev.result;
}
`,
};
const command = new CreateResolverCommand(input);
await client.send(command);
await sleep(200);
const endMsg = 'Attached resolver to schema type ' + yellow(typeName) + ' field ' + yellow(fieldName);
succeedSpinner(endMsg);
loggerDebug(endMsg);
}