| 2 | import { PluginInterface, NavigationItemInterface } from '../lib/interface'; |
| 3 | |
| 4 | export default class NavigationObjects extends Plugin implements PluginInterface { |
| 5 | |
| 6 | getTypes(buildForType: string): NavigationItemInterface[] { |
| 7 | |
| 8 | let objects = this.document.types |
| 9 | .filter(type => { |
| 10 | return type.kind === OBJECT && |
| 11 | (!this.queryType || this.queryType.name !== type.name) && |
| 12 | (!this.mutationType || this.mutationType.name !== type.name) && |
| 13 | (!this.subscriptionType || this.subscriptionType.name !== type.name); |
| 14 | }); |
| 15 | |
| 16 | return objects |
| 17 | .map(type => new NavigationItem( |
| 18 | type.name, |
| 19 | this.url(type), |
| 20 | type.name === buildForType |
| 21 | )); |
| 22 | } |
| 23 | |
| 24 | getNavigations(buildForType: string) { |
| 25 | |
| 26 | const types: NavigationItemInterface[] = this.getTypes(buildForType); |
| 27 | |
| 28 | if (types.length === 0) |
| 29 | return []; |
| 30 | |
| 31 | return [ |
| 32 | new NavigationSection('Objects', types) |
| 33 | ]; |
| 34 | } |
| 35 | } |
nothing calls this directly
no outgoing calls
no test coverage detected