Skip to content

Instantly share code, notes, and snippets.

@AugustoCalaca
Forked from sibelius/debugRelay.ts
Created April 12, 2021 14:54
Show Gist options
  • Save AugustoCalaca/66eb65e55e0496137322ec10e1d2dda3 to your computer and use it in GitHub Desktop.
Save AugustoCalaca/66eb65e55e0496137322ec10e1d2dda3 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