@@ -447,7 +447,7 @@ export function getAutocompleteSuggestions(
447
447
kind : CompletionItemKind . Function ,
448
448
insertText : options ?. fillLeafsOnComplete
449
449
? type . name + '\n'
450
- : undefined ,
450
+ : type . name ,
451
451
insertTextMode : InsertTextMode . adjustIndentation ,
452
452
} ) ) ,
453
453
) ;
@@ -462,7 +462,7 @@ export function getAutocompleteSuggestions(
462
462
kind : CompletionItemKind . Function ,
463
463
insertText : options ?. fillLeafsOnComplete
464
464
? type . name + '\n$1'
465
- : undefined ,
465
+ : type . name ,
466
466
insertTextMode : InsertTextMode . adjustIndentation ,
467
467
insertTextFormat : InsertTextFormat . Snippet ,
468
468
} ) ) ,
@@ -486,9 +486,9 @@ export function getAutocompleteSuggestions(
486
486
if ( kind === RuleKinds . DIRECTIVE ) {
487
487
return getSuggestionsForDirective ( token , state , schema , kind ) ;
488
488
}
489
- // if (kind === RuleKinds.DIRECTIVE_DEF) {
490
- // return getSuggestionsForDirectiveArguments(token, state, schema, kind);
491
- // }
489
+ if ( kind === RuleKinds . DIRECTIVE_DEF ) {
490
+ return getSuggestionsForDirectiveArguments ( token , state , schema , kind ) ;
491
+ }
492
492
493
493
return [ ] ;
494
494
}
@@ -844,7 +844,7 @@ function getSuggestionsForImplements(
844
844
kind : CompletionItemKind . Interface ,
845
845
type,
846
846
} as CompletionItem ;
847
- if ( type ?. description && type . description . length ) {
847
+ if ( type ?. description ) {
848
848
result . documentation = type . description ;
849
849
}
850
850
// TODO: should we report what an interface implements in CompletionItem.detail?
@@ -898,7 +898,7 @@ function getSuggestionsForFragmentTypeConditions(
898
898
const namedType = getNamedType ( type ) ;
899
899
return {
900
900
label : String ( type ) ,
901
- documentation : namedType ?. description as string | undefined ,
901
+ documentation : ( namedType ?. description as string | undefined ) || '' ,
902
902
kind : CompletionItemKind . Field ,
903
903
} ;
904
904
} ) ,
@@ -949,6 +949,7 @@ function getSuggestionsForFragmentSpread(
949
949
relevantFrags . map ( frag => ( {
950
950
label : frag . name . value ,
951
951
detail : String ( typeMap [ frag . typeCondition . name . value ] ) ,
952
+ documentation : `fragment ${ frag . name . value } on ${ frag . typeCondition . name . value } ` ,
952
953
labelDetails : {
953
954
detail : `fragment ${ frag . name . value } on ${ frag . typeCondition . name . value } ` ,
954
955
} ,
@@ -1069,7 +1070,7 @@ function getSuggestionsForVariableDefinition(
1069
1070
// TODO: couldn't get Exclude<> working here
1070
1071
inputTypes . map ( ( type : GraphQLNamedType ) => ( {
1071
1072
label : type . name ,
1072
- documentation : type ?. description ?. length ? type . description : undefined ,
1073
+ documentation : type ?. description || '' ,
1073
1074
kind : CompletionItemKind . Variable ,
1074
1075
} ) ) ,
1075
1076
) ;
@@ -1089,9 +1090,7 @@ function getSuggestionsForDirective(
1089
1090
token ,
1090
1091
directives . map ( directive => ( {
1091
1092
label : directive . name ,
1092
- documentation : directive ?. description ?. length
1093
- ? directive . description
1094
- : undefined ,
1093
+ documentation : directive ?. description || '' ,
1095
1094
kind : CompletionItemKind . Function ,
1096
1095
} ) ) ,
1097
1096
) ;
@@ -1101,22 +1100,22 @@ function getSuggestionsForDirective(
1101
1100
1102
1101
// I thought this added functionality somewhere, but I couldn't write any tests
1103
1102
// to execute it. I think it's handled as Arguments
1104
- // function getSuggestionsForDirectiveArguments(
1105
- // token: ContextToken,
1106
- // state: State,
1107
- // schema: GraphQLSchema,
1108
- // _kind: string,
1109
- // ): Array<CompletionItem> {
1110
- // const directive = schema.getDirectives().find(d => d.name === state.name);
1111
- // return hintList(
1112
- // token,
1113
- // directive?.args.map(arg => ({
1114
- // label: arg.name,
1115
- // documentation: arg.description || '',
1116
- // kind: CompletionItemKind.Field,
1117
- // })) || [],
1118
- // );
1119
- // }
1103
+ function getSuggestionsForDirectiveArguments (
1104
+ token : ContextToken ,
1105
+ state : State ,
1106
+ schema : GraphQLSchema ,
1107
+ _kind : string ,
1108
+ ) : Array < CompletionItem > {
1109
+ const directive = schema . getDirectives ( ) . find ( d => d . name === state . name ) ;
1110
+ return hintList (
1111
+ token ,
1112
+ directive ?. args . map ( arg => ( {
1113
+ label : arg . name ,
1114
+ documentation : arg . description || '' ,
1115
+ kind : CompletionItemKind . Field ,
1116
+ } ) ) || [ ] ,
1117
+ ) ;
1118
+ }
1120
1119
1121
1120
export function getTokenAtPosition (
1122
1121
queryText : string ,
0 commit comments