Skip to content

Instantly share code, notes, and snippets.

@ksaldana1
Created March 13, 2020 01:25
Show Gist options
  • Save ksaldana1/d2f5926e4c2b10aff1a38d00f852c0e2 to your computer and use it in GitHub Desktop.
Save ksaldana1/d2f5926e4c2b10aff1a38d00f852c0e2 to your computer and use it in GitHub Desktop.
gql_example_ts_trunc_1
const Message: React.FC<MessageProps> = ({ message }) => {
switch (message.author.__typename) {
case "User": {
return <div>{`${message.author.name}: ${message.text}`}</div>;
}
case "Guest": {
return <div>{`${message.author.placeholder}: ${message.text}`}</div>;
}
case "%other": {
return null;
}
default: {
assertNever(message.author);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment