Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use mysql to save the message? #738

Closed
tranvannhat opened this issue Feb 1, 2018 · 6 comments
Closed

Can I use mysql to save the message? #738

tranvannhat opened this issue Feb 1, 2018 · 6 comments

Comments

@tranvannhat
Copy link

@tranvannhat tranvannhat commented Feb 1, 2018

Issue Description

Can I use mysql to save the message?
Can I customize the message object? Compulsory use of your format?

@xpsdeset
Copy link

@xpsdeset xpsdeset commented Feb 22, 2018

Yes you can use mysql to save messages.
Use the text generated by send button to insert into your mysql.
Also you can use any format just map it when populating the chats.

@xcarpentier
Copy link
Collaborator

@xcarpentier xcarpentier commented Feb 23, 2018

Hi, I add this question to readme/questions ;)

@Simwenya
Copy link

@Simwenya Simwenya commented May 6, 2018

how do you connect giftedChat to mysql

@tranvannhat
Copy link
Author

@tranvannhat tranvannhat commented May 17, 2018

thanks bro. Closed

@LesedimotaungNC
Copy link

@LesedimotaungNC LesedimotaungNC commented Dec 10, 2018

a graphql example would be awesome

@josemiguelo
Copy link

@josemiguelo josemiguelo commented Jul 11, 2019

a graphql example would be awesome

This has worked for me (you have to use withApollo HOC and use prop 'client'):

....
const onSend = (newMessages: IMessage[] = []) => {
    newMessages.forEach(message => {
      client
        .mutate({
          variables: {
            ...
          },
          mutation: YOUR_MUTATION,
        })

        .then(response => {
          setMessagesHistory(prevMessages =>
            GiftedChat.append(prevMessages, message)
          )
        })
        .catch(error => {
          // error logic
        })
    })
  }
....
 return (

        <GiftedChat
          messages={yourMessagesFromState}
          onSend={messages => onSend(messages)}
          .....
        />
 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants