Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created April 7, 2021 02:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sibelius/98457814ab9c7b4e0cbeb433395ae02a to your computer and use it in GitHub Desktop.
Save sibelius/98457814ab9c7b4e0cbeb433395ae02a to your computer and use it in GitHub Desktop.
debug relay utils
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