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

Method field

plugins/document.schema/index.ts:230–263  ·  view source on GitHub ↗
(field: Field)

Source from the content-addressed store, hash-verified

228 }
229
230 field(field: Field): string {
231
232 const fieldDescription = this.description(field.description);
233 const argumentsDescription = this.argumentsDescription(field);
234
235 if (fieldDescription.length > 0 && argumentsDescription.length)
236 fieldDescription.push(html.comment(''));
237
238 const fieldDefinition = field.args.length > 0 && this.fieldLength(field) > MAX_CODE_LEN ?
239
240 // Multiline definition:
241 // fieldName(
242 // argumentName: ArgumentType, \n ...
243 // ): ReturnType [@deprecated...]
244 [
245 html.property(field.name) + '(',
246 ...this.argumentsMultiline(field).map(l => html.tab(l)),
247 '): ' + html.useIdentifier(field.type, this.url(field.type)) + ' ' + this.deprecated(field)
248 ] :
249
250 // Single line
251 // fieldName(argumentName: ArgumentType): ReturnType [@deprecated...]
252 [
253 html.property(field.name) + this.arguments(field) + ': ' +
254 html.useIdentifier(field.type, this.url(field.type)) + ' ' + this.deprecated(field)
255 ];
256
257 return ([] as string[])
258 .concat(fieldDescription)
259 .concat(argumentsDescription)
260 .concat(fieldDefinition)
261 .map(line => html.line(html.tab(line)))
262 .join('');
263 }
264
265 fieldLength(field: Field): number {
266

Callers 1

fieldsMethod · 0.95

Calls 11

descriptionMethod · 0.95
argumentsDescriptionMethod · 0.95
fieldLengthMethod · 0.95
argumentsMultilineMethod · 0.95
deprecatedMethod · 0.95
argumentsMethod · 0.95
commentMethod · 0.80
propertyMethod · 0.80
tabMethod · 0.80
useIdentifierMethod · 0.80
lineMethod · 0.80

Tested by

no test coverage detected