Reputation: 1397
I have this graphql query to create a new item. This query has worked for months, then I left the app for a while, and suddenly it doesn't work now. It gives me the error above which is off for a creation request as it should create the ID.
Error:
Variable 'input' has coerced Null value for NonNull type 'ID!'
Code:
const addArticle = async (event) => {
const input = { ...article, data: JSON.stringify(article.data) };
return await API.graphql({
query: createArticle,
variables: { input: input },
authMode: "AMAZON_COGNITO_USER_POOLS",
});
};
GraphQL:
type Article
@model
@key(name: "byTag", fields: ["tagId", "dateWritten"])
@key(name: "bySource", fields: ["sourceId", "dateWritten"]) {
id: ID!
link: AWSURL!
title: String!
dateWritten: String!
articleDate: AWSDateTime
data: AWSJSON!
approved: Boolean!
admin: Boolean!
tagId: ID!
creatorId: ID!
creator: User @connection(fields: ["creatorId"])
sourceId: ID!
source: Source @connection(fields: ["sourceId"])
}
Upvotes: 1
Views: 1954
Reputation: 1397
I eventually figured out that the problem with the query was that a separate property (which was required) had not been filled and was null. This caused the query not to work.
So, it's just a bad error message.
Upvotes: 2