Skip to content

Instantly share code, notes, and snippets.

@alizhdanov
Created October 24, 2018 16:05
Show Gist options
  • Save alizhdanov/8216849363ec57b9c697b0ccfeb01020 to your computer and use it in GitHub Desktop.
Save alizhdanov/8216849363ec57b9c697b0ccfeb01020 to your computer and use it in GitHub Desktop.
GraphQL Boolean serialization
function serializeBoolean(value) {
if (typeof value === 'boolean') {
return value;
}
if (isFinite(value)) {
return value !== 0;
}
throw new TypeError(
`Boolean cannot represent a non boolean value: ${inspect(value)}`,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment