Skip to content

Commit b08cebc

Browse files
committed
more coverage?
1 parent 45faf79 commit b08cebc

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

packages/graphql-language-service/src/interface/__tests__/__schema__/StarWarsSchema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Droid implements Character {
4141
input InputType {
4242
key: String!
4343
value: Int = 42
44+
obj: InputType
4445
}
4546

4647
interface TestInterface {

packages/graphql-language-service/src/interface/__tests__/getAutocompleteSuggestions-test.ts

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,20 @@ describe('getAutocompleteSuggestions', () => {
528528
expect(testSuggestions('query @', new Position(0, 7))).toEqual([]);
529529
});
530530

531-
it('provides correct testInput suggestions', () => {
531+
it('provides correct directive field suggestions', () => {
532+
expect(
533+
testSuggestions('{ test @deprecated(', new Position(0, 19)),
534+
).toEqual([
535+
{
536+
command: suggestionCommand,
537+
label: 'reason',
538+
insertTextFormat: 2,
539+
insertText: 'reason: ',
540+
},
541+
]);
542+
});
543+
544+
it('provides correct testInput type field suggestions', () => {
532545
expect(
533546
testSuggestions('{ inputTypeTest(args: {', new Position(0, 23)),
534547
).toEqual([
@@ -539,6 +552,41 @@ describe('getAutocompleteSuggestions', () => {
539552
insertTextFormat: 2,
540553
command: suggestionCommand,
541554
},
555+
{
556+
detail: 'InputType',
557+
label: 'obj',
558+
insertText: 'obj: {\n $1\n}',
559+
command: suggestionCommand,
560+
insertTextFormat: 2,
561+
},
562+
{
563+
label: 'value',
564+
detail: 'Int',
565+
insertText: 'value: ',
566+
insertTextFormat: 2,
567+
command: suggestionCommand,
568+
},
569+
]);
570+
});
571+
572+
it('provides correct nested testInput type field suggestions', () => {
573+
expect(
574+
testSuggestions('{ inputTypeTest(args: { obj: {', new Position(0, 30)),
575+
).toEqual([
576+
{
577+
label: 'key',
578+
detail: 'String!',
579+
insertText: 'key: ',
580+
insertTextFormat: 2,
581+
command: suggestionCommand,
582+
},
583+
{
584+
detail: 'InputType',
585+
label: 'obj',
586+
insertText: 'obj: {\n $1\n}',
587+
command: suggestionCommand,
588+
insertTextFormat: 2,
589+
},
542590
{
543591
label: 'value',
544592
detail: 'Int',
@@ -705,6 +753,38 @@ describe('getAutocompleteSuggestions', () => {
705753
expect(testSuggestions('type Type @', new Position(0, 11))).toEqual([
706754
{ label: 'onAllDefs' },
707755
]));
756+
it('provides correct suggestions on object field w/ .graphqls', () =>
757+
expect(
758+
testSuggestions('type Type {\n aField: s', new Position(0, 23), [], {
759+
uri: 'schema.graphqls',
760+
ignoreInsert: true,
761+
}),
762+
).toEqual([
763+
{ label: 'Episode' },
764+
{ label: 'String' },
765+
{ label: 'TestInterface' },
766+
{ label: 'TestType' },
767+
{ label: 'TestUnion' },
768+
]));
769+
770+
it('provides correct argument type suggestions on directive definitions', () =>
771+
expect(
772+
testSuggestions(
773+
'directive @skip(if: ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT',
774+
new Position(0, 19),
775+
[],
776+
{
777+
ignoreInsert: true,
778+
},
779+
),
780+
).toEqual([
781+
{ label: 'Boolean' },
782+
{ label: 'Episode' },
783+
{ label: 'InputType' },
784+
{ label: 'Int' },
785+
{ label: 'String' },
786+
]));
787+
708788
it('provides correct suggestions on object field w/ .graphqls', () =>
709789
expect(
710790
testSuggestions('type Type {\n aField: s', new Position(0, 23), [], {

packages/graphql-language-service/src/interface/getAutocompleteSuggestions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ function getSuggestionsForFieldNames(
654654
labelDetails: {
655655
detail: ' ' + field.type.toString(),
656656
},
657+
657658
type: field.type,
658659
};
659660
if (options?.fillLeafsOnComplete) {

0 commit comments

Comments
 (0)