How to use the @aws-amplify/api.graphqlOperation function in @aws-amplify/api

To help you get started, we’ve selected a few @aws-amplify/api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yhenni1989 / Zopher / src / components / Posts.js View on Github external
deletePost = async (post) => {
    const postId = await post['id'] 
    try {
      await API.graphql(graphqlOperation(deletePost, { id: postId }))
      await this.componentDidMount()
      // console.log('Post successfully deleted.')
    } catch (err) {
      console.log('Error deleting post.', err)
    }
  }
github yhenni1989 / Zopher / src / components / Posts.js View on Github external
deleteLike = async (likeUserObject) => {
    const likeId = await likeUserObject[0]['id']
    try {
      await API.graphql(graphqlOperation(deleteLike, { id: likeId }))
      await this.componentDidMount()
    } catch (err) {
      console.log('Error deleting like.', err)
    }
  }
github dabit3 / full-stack-serverless-code / graphql / src / App.js View on Github external
async function fetchNotes() {
    try {
      const notesData = await API.graphql(graphqlOperation(listNotes))
      dispatch({ type: 'SET_NOTES', notes: notesData.data.listNotes.items })
    } catch (err) {
      console.log('error: ', err)
      dispatch({ type: 'ERROR' })
    }
  }
github yhenni1989 / Plush / src / components / Feed.js View on Github external
createFlagPicture = async (uri) => {
    const key = await uri.substring(uri.indexOf('2F') + 2)
    const pictureObject = await this.state.pictures.filter(photo => photo.file.key === key)
    const pictureId = await pictureObject[0].id
    const flag = {
      id: pictureId,
      flagOwnerId: this.state.flagOwnerId,
      flagOwnerUsername: this.state.flagOwnerUsername,
    }
    try {
      await API.graphql(graphqlOperation(CreateFlagPicture, flag))
      await this.componentDidMount()
    } catch (err) {
      console.log('Error creating like.', err)
    }
  }
github dabit3 / full-stack-serverless-code / graphql / src / App.js View on Github external
async function createNote() {
    const { form } = state
    if (!form.name || !form.description) return alert('please enter a name and description')
    const note = { ...form, clientId: CLIENT_ID, completed: false }
    dispatch({ type: 'ADD_NOTE', note })
    dispatch({ type: 'RESET_FORM' })
    try {
      await API.graphql(graphqlOperation(CreateNote, { input: note }))
      console.log('successfully created note!')
    } catch (err) {
      console.log("error: ", err)
    }
  }