I'm running into the error: Variable 'input' has coerced Null value for NonNull type 'SaveCardInput!'
when I try to run the following simple graphqlOperation:
import { API } from "aws-amplify";
import { graphqlOperation } from "@aws-amplify/api-graphql";
import { requestApproval } from "../src/graphql/mutations";
export async function saveCardLambda(id: string) {
try {
const lambdaResponse = await API.graphql(
graphqlOperation(requestApproval),
{
input: {id}
}
);
return lambdaResponse
} catch (error) {
throw error; // Error: Variable 'input' has coerced Null value for NonNull type 'SaveCardInput!'
}
}
// ../src/graphql/mutations
export const requestApproval = /* GraphQL */ `
mutation RequestApproval($input: SaveCardInput!) {
requestApproval(input: $input)
}
`;
// schema.graphql
input SaveCardInput {
id: ID!
}
I suspect the problem is with the input:{id}
line, but I can't figure it out. My problem appeared to be similar to this: AWS GraphQL: Variable 'input' has coerced Null value for NonNull type 'Input!' but the fix didn't work.