import { GraphQLSchema , GraphQLNamedType , EnumTypeDefinitionNode , ObjectTypeDefinitionNode } from 'graphql' ; import { TsVisitor } from './visitor' ; import { TypeScriptPluginConfig } from './config' ; import autoBind from 'auto-bind' ; export class TsIntrospectionVisitor extends TsVisitor { private typesToInclude : GraphQLNamedType [ ] = [ ] ; constructor ( schema , pluginConfig = { } , typesToInclude ) { super ( schema , pluginConfig ) ; this . typesToInclude = typesToInclude ; autoBind ( this ) ; } DirectiveDefinition ( ) { return null ; } ObjectTypeDefinition ( node , key , parent ) { const name = node . name as any ; if ( this . typesToInclude . some ( type => type . name === name ) ) { return super . ObjectTypeDefinition ( node , key , parent ) ; } return null ; } EnumTypeDefinition ( node ) { const name = node . name as any ; if ( this . typesToInclude . some ( type => type . name === name ) ) { return super . EnumTypeDefinition ( node ) ; } return null ; } }