Created
November 20, 2018 17:38
-
-
Save garethpbk/d15e6747acb263142a2fa4a89b027510 to your computer and use it in GitHub Desktop.
apollo-link-state createNewUser function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createNewUser = async (e, action) => { | |
e.preventDefault(); | |
const currentUsers = client.readQuery({ query: GET_ALL_USERS_QUERY }); | |
const id = currentUsers.users.length + 1; | |
await action({ | |
variables: { | |
input: { | |
id, | |
...this.state, | |
}, | |
}, | |
}); | |
this.setState({ | |
name: '', | |
username: '', | |
email: '', | |
address: { | |
street: '', | |
suite: '', | |
city: '', | |
zipcode: '', | |
geo: { | |
lat: '', | |
lng: '', | |
}, | |
}, | |
phone: '', | |
website: '', | |
company: { | |
name: '', | |
catchPhrase: '', | |
bs: '', | |
}, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment