Skip to content

Commit d19672e

Browse files
committed
fix: inputType for getTypeInfo and offsets
1 parent b16997a commit d19672e

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

Diff for: packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ describe('MessageProcessor with config', () => {
436436
character: 0,
437437
},
438438
end: {
439-
line: 102 + offset,
439+
line: 103 + offset,
440440
character: 1,
441441
},
442442
});
@@ -450,11 +450,11 @@ describe('MessageProcessor with config', () => {
450450
// this might break, please adjust if you see a failure here
451451
expect(serializeRange(schemaDefs[0].range)).toEqual({
452452
start: {
453-
line: 104 + offset,
453+
line: 105 + offset,
454454
character: 0,
455455
},
456456
end: {
457-
line: 112 + offset,
457+
line: 113 + offset,
458458
character: 1,
459459
},
460460
});

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -704,14 +704,14 @@ describe('getAutocompleteSuggestions', () => {
704704

705705
// TODO: decide if we want this. Discussing with @benjie, we might want to actually give the user flexibility here,
706706
// instead of being strict
707-
// it('provides no more field suggestions once a oneOf field is chose and a user begins typing another field', () => {
708-
// expect(
709-
// testSuggestions(
710-
// '{ oneOfInputTypeTest(oneOf: { value: 2 d',
711-
// new Position(0, 40),
712-
// ),
713-
// ).toEqual([]);
714-
// });
707+
it('provides no more field suggestions once a oneOf field is chose and a user begins typing another field', () => {
708+
expect(
709+
testSuggestions(
710+
'{ oneOfInputTypeTest(oneOf: { value: 2 d',
711+
new Position(0, 40),
712+
),
713+
).toEqual([]);
714+
});
715715

716716
it('provides correct field name suggestion inside inline fragment', () => {
717717
expect(

Diff for: packages/graphql-language-service/src/interface/getAutocompleteSuggestions.ts

+2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ export function getAutocompleteSuggestions(
315315
// @oneOf logic!
316316
console.log(state.prevState?.prevState?.kind, !!typeInfo.inputType);
317317
if (
318+
typeInfo?.inputType &&
319+
'isOneOf' in typeInfo.inputType &&
318320
typeInfo?.inputType?.isOneOf === true &&
319321
(state.prevState?.prevState?.kind !== 'Argument' || token.string !== '{')
320322
) {

Diff for: packages/graphql-language-service/src/parser/getTypeInfo.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,14 @@ export function getTypeInfo(
245245
? objectType.getFields()
246246
: null;
247247
inputType = objectType;
248-
console.log(inputType);
249248
break;
250249
// TODO: needs tests
251250
case RuleKinds.OBJECT_FIELD:
252251
const objectField =
253252
state.name && objectFieldDefs ? objectFieldDefs[state.name] : null;
254-
inputType = objectField?.type;
253+
if (objectField?.type) {
254+
inputType = objectField?.type;
255+
}
255256
// @ts-expect-error
256257
fieldDef = objectField as GraphQLField<null, null>;
257258
type = fieldDef ? fieldDef.type : null;

Diff for: packages/graphql-language-service/src/types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import type {
2929
GraphQLObjectType,
3030
GraphQLType,
3131
GraphQLDirective,
32-
GraphQLInputType,
33-
GraphQLInputObjectType,
3432
} from 'graphql';
3533

3634
export type Maybe<T> = T | null | undefined;

0 commit comments

Comments
 (0)