Created
June 2, 2019 18:29
-
-
Save JeffML/98f1de8b119f87a8fd220006cde865c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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