-
-
Save AugustoCalaca/66eb65e55e0496137322ec10e1d2dda3 to your computer and use it in GitHub Desktop.
debug relay utils
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 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