Created
August 12, 2018 20:12
-
-
Save jakeleboeuf/0eb4eb7a0b23268c885b8c8f45eda6cb to your computer and use it in GitHub Desktop.
Token resolvers
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
import { GET_TOKENS } from "../queries"; | |
export default async (_, __, { cache }) => { | |
const { getTokens: { tokens } = {} } = cache.readQuery({ | |
query: GET_TOKENS, | |
}); | |
const defaultTokens = { | |
authToken: null, | |
refreshToken: null, | |
}; | |
return { | |
__typename: "Tokens", | |
...defaultTokens, | |
...tokens, | |
}; | |
}; |
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
import { GET_TOKENS } from "../queries"; | |
export default (_, { input }, { cache }) => { | |
const { getTokens: { tokens } = {} } = cache.readQuery({ | |
query: GET_TOKENS, | |
}); | |
const data = { | |
getTokens: { | |
__typename: "Tokens", | |
...tokens, | |
...input, | |
}, | |
}; | |
cache.writeData({ data }); | |
return null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment