A tool that generates a strongly typed client library for any GraphQL endpoint. The client allows writing GraphQL queries as plain JS objects (with type safety, awesome code completion experience, custom scalar type mapping, type guards and more)
MIT License
212
stars
18
forks
source link
generate TS type guard functions for types, unions and interfaces based on __typename #8
export function isFooBar(obj: any): obj is FooBar {
if (!obj.__typename) {
throw new Error('__typename is required')
}
return ~['Foo', 'Bar'].indexOf(obj.__typename)
}
and similar ones for interfaces and specific types
e.g. for GraphQL like
generate a function
and similar ones for interfaces and specific types