Я использую ReactJS и aws-amplify для выполнения операций graphql.
КОД:
import {
API,
graphqlOperation
} from 'aws-amplify';
import { UpdateInput } from './mutations.js';
// Call mutation
const input = { /* some values */ };
API.graphql(graphqlOperation(UpdateInput, input)).then(...);
Определение мутации GraphQL:
export const UpdateInput = `mutation UpdateInput($input: Input!) {
updateInput(input: $input) {
id,
name
}
}`
Схема GraphQL:
input Input {
id: ID!
name: String
}
type Mutation {
updateInput(input: Input!): String
}
Однако я получаю сообщение об ошибке:
[Log] Variable 'input' has coerced Null value for NonNull type 'Input!'
Используя консоль AWS, моя мутация работает, а input - NonNull (с использованием отладчика)
Есть идеи, что вызывает ошибку?





Ключевым был input в мутации updateInput.
updateInput(input: Input!): String
// ^^^^^ input key
Таким образом, необходимо указать правильный ключ в переданной переменной.
const variables = {
input: someData, // key is "input" based on the mutation above
};
API.graphql(graphqlOperation(UpdateInput, variables)).then(...);