0
I am creating a react app using amplify and graphql
my graphql schema is
type Note @model @auth(rules: [ { allow: public } ] ){
id: ID!
name: String!
description: String
image: String
noteBook: NoteBook!
}
type NoteBook @model @auth(rules: [ { allow: public } ] ){
id: ID!
name: String!
notes: [Note!]
}
I have three buttons and these are their associated functions,
Create Notebook
async function handleCreateNoteBook(){
const data = {
name: 'my 1st notebook'
}
await API.graphql({
query: createNoteBook,
variables: {input: data}
})
}
Create Note
async function handleCreateNote(){
const data = {
name: 'test',
description: 'this is a test note',
noteBook: 'my 2nd notebook'
}
await API.graphql({
query: createNoteMutation,
variables: {input: data}
})
}
Show Notes
async function handleShow(){
const noteBookData = await API.graphql({query: listNoteBooks})
const notesData = await API.graphql({query: listNotes})
console.log(noteBookData)
}
However,
while creating a new note,
I am getting the following error
[object Object]
at handleError (https://localhost:3000/static/js/bundle.js:80145:58)
at https://localhost:3000/static/js/bundle.js:80168:7
I am new to graphql. What seems to be the issue?
1
that
[object Object]
means, you are trying to perform an operation on thatobject Object
without converting that to the expected data type! Try doingJSON.parse(noteBookData)
.59 mins ago
|