Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created May 6, 2020 13:23
Show Gist options
  • Save sibelius/3432bd291fc8b6060e59488eecad3dc8 to your computer and use it in GitHub Desktop.
Save sibelius/3432bd291fc8b6060e59488eecad3dc8 to your computer and use it in GitHub Desktop.
using JSON.stringify to strip some relay metadata from console.log
const excludeKeys = ['__fragments', '__id', '__fragmentOwner'];
// strip __fragments, __id, __fragmentOwne
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)));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment