appsync-gateway
appsync-gateway copied to clipboard
The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
I get this error:
{
"errorType": "TypeError",
"errorMessage": "The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined",
"trace": [
"TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined",
" at Hmac.update (internal/crypto/hash.js:82:11)",
" at Object.hmac (/var/task/node_modules/aws-sdk/lib/util.js:423:50)",
" at Object.getSigningKey (/var/task/node_modules/aws-sdk/lib/signers/v4_credentials.js:74:35)",
" at V4.signature (/var/task/node_modules/aws-sdk/lib/signers/v4.js:98:36)",
" at V4.authorization (/var/task/node_modules/aws-sdk/lib/signers/v4.js:93:36)",
" at V4.addAuthorization (/var/task/node_modules/aws-sdk/lib/signers/v4.js:35:12)",
" at signRequest (/var/task/node_modules/@crft/appsync-gateway/dist/credentials.js:20:12)",
" at IAMCredentialsStrategy.sign (/var/task/node_modules/@crft/appsync-gateway/dist/credentials.js:42:16)",
" at GraphQLGateway.runQuery (/var/task/node_modules/@crft/appsync-gateway/dist/gateway.js:28:44)",
" at module.exports.handler (/var/task/src/PostConfirmation.js:40:19)"
]
}
I use the IAM strategy and I verified that all attributes are set (key, secret, token and region).
My lambda tries to call a mutation like so:
const createUser = `
mutation createUser($input: CreateUserInput!) {
createUser(input: $input) {
id
name
email
}
}
`
const newUser = <someUserData>
await gateway.runQuery({
operationName: 'createUser',
query: createUser,
variables: {
input: newUser
}
})
Am I missing something? To me it looks like the signing doesn't work, because AWS signer expects different parameters.