Instantly share code, notes, and snippets.

Embed
What would you like to do?
/* @flow */
export class GraphQLSchema {
getQueryType() {
return "foobar";
}
}
/* @flow */
export class ThirdPartyGraphQLSchema {
getQueryType() {
return "fizfuz";
}
}
/* @flow */
export interface IGraphQLSchema {
getQueryType(): string
};
/* @flow */
import type { IGraphQLSchema } from './types';
import { GraphQLSchema } from './class1';
import { ThirdPartyGraphQLSchema } from './class2';
export function printSchema(schema: IGraphQLSchema) {
console.log(schema.getQueryType());
}
printSchema(new GraphQLSchema());
printSchema(new ThirdPartyGraphQLSchema());
/* @flow */
import type { IGraphQLSchema } from './types';
export function isGraphqlSchema(schema: IGraphQLSchema) {
return typeof schema.getQueryType === 'function';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment