MCPcopy Create free account
hub / github.com/2fd/graphdoc / code

Method code

plugins/document.schema/index.ts:57–97  ·  view source on GitHub ↗
(buildForType ? : string)

Source from the content-addressed store, hash-verified

55 }
56
57 code(buildForType ? : string): string {
58
59 if (!buildForType)
60 return this.schema(this.document);
61
62 const directive = this.document
63 .directives
64 .find((directive) => directive.name === (buildForType as string));
65
66 if (directive)
67 return this.directive(directive);
68
69 const type = this.document
70 .types
71 .find((type) => type.name === (buildForType as string));
72
73 if (type) {
74 switch (type.kind) {
75
76 case SCALAR:
77 return this.scalar(type);
78
79 case OBJECT:
80 return this.object(type);
81
82 case INTERFACE:
83 return this.interfaces(type);
84
85 case UNION:
86 return this.union(type);
87
88 case ENUM:
89 return this.enum(type);
90
91 case INPUT_OBJECT:
92 return this.inputObject(type);
93 }
94 }
95
96 throw new TypeError('Unexpected type: ' + buildForType);
97 }
98
99 argument(arg: InputValue): string {
100

Callers 1

getDocumentsMethod · 0.95

Calls 8

schemaMethod · 0.95
directiveMethod · 0.95
scalarMethod · 0.95
objectMethod · 0.95
interfacesMethod · 0.95
unionMethod · 0.95
enumMethod · 0.95
inputObjectMethod · 0.95

Tested by

no test coverage detected