UNPKG

865 BJavaScriptView Raw
1import autoBind from 'auto-bind';
2import { TsVisitor } from './visitor.js';
3export class TsIntrospectionVisitor extends TsVisitor {
4 constructor(schema, pluginConfig = {}, typesToInclude) {
5 super(schema, pluginConfig);
6 this.typesToInclude = [];
7 this.typesToInclude = typesToInclude;
8 autoBind(this);
9 }
10 DirectiveDefinition() {
11 return null;
12 }
13 ObjectTypeDefinition(node, key, parent) {
14 const name = node.name;
15 if (this.typesToInclude.some(type => type.name === name)) {
16 return super.ObjectTypeDefinition(node, key, parent);
17 }
18 return null;
19 }
20 EnumTypeDefinition(node) {
21 const name = node.name;
22 if (this.typesToInclude.some(type => type.name === name)) {
23 return super.EnumTypeDefinition(node);
24 }
25 return null;
26 }
27}