Skip to content

Instantly share code, notes, and snippets.

@JeffML
Created June 2, 2019 18:29
Show Gist options
  • Save JeffML/98f1de8b119f87a8fd220006cde865c1 to your computer and use it in GitHub Desktop.
Save JeffML/98f1de8b119f87a8fd220006cde865c1 to your computer and use it in GitHub Desktop.
// Editor.js
const LOGIN = gql`
mutation login {
login(email:"${faker.internet.email}")
}
`
const Submit = (props) => {
return <Mutation mutation={LOGIN} update={(cache, { data }) => sessionStorage.setItem('auth', data.login)}>
{
mLogin => {
if (!sessionStorage.auth) mLogin()
return <Mutation mutation={BOOK}>
{mBook => (
<input type="submit" value="Submit Changes"
onClick={evt => submitChanges(evt, mBook)} />
)}
</Mutation>
}
}
</Mutation>
};
// App.js
const client = new ApolloClient({uri: 'http://localhost:4000/', headers: {authorization: sessionStorage.getItem('auth')}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment