Created
April 7, 2021 02:13
-
-
Save sibelius/98457814ab9c7b4e0cbeb433395ae02a to your computer and use it in GitHub Desktop.
debug relay utils
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
import prettyFormat from 'pretty-format'; | |
const excludeKeys = ['__fragments', '__id', '__fragmentOwner']; | |
// strip __fragments, __id, __fragmentOwne | |
export const relayTransform = (key: string, value: string) => { | |
if (excludeKeys.includes(key)) { | |
return undefined; | |
} | |
return value; | |
}; | |
export const debugRelay = (value: any) => { | |
// eslint-disable-next-line | |
console.log(JSON.parse(JSON.stringify(value, relayTransform))); | |
}; | |
export const consoleAll = (val: any) => { | |
const safeValue = JSON.parse(JSON.stringify(val, relayTransform)); | |
// eslint-disable-next-line | |
console.log(prettyFormat(safeValue)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment