Skip to content

Commit 478781d

Browse files
committed
GraphQLInputObjectType: remove check that duplicate TS types
Context: Continuation of graphql#3642
1 parent a68dc42 commit 478781d

File tree

2 files changed

+9
-44
lines changed

2 files changed

+9
-44
lines changed

src/type/__tests__/definition-test.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -566,34 +566,6 @@ describe('Type System: Input Objects', () => {
566566
});
567567
});
568568

569-
describe('Input Object fields must not have resolvers', () => {
570-
it('rejects an Input Object type with resolvers', () => {
571-
const inputObjType = new GraphQLInputObjectType({
572-
name: 'SomeInputObject',
573-
fields: {
574-
// @ts-expect-error (Input fields cannot have resolvers)
575-
f: { type: ScalarType, resolve: dummyFunc },
576-
},
577-
});
578-
expect(() => inputObjType.getFields()).to.throw(
579-
'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.',
580-
);
581-
});
582-
583-
it('rejects an Input Object type with resolver constant', () => {
584-
const inputObjType = new GraphQLInputObjectType({
585-
name: 'SomeInputObject',
586-
fields: {
587-
// @ts-expect-error (Input fields cannot have resolvers)
588-
f: { type: ScalarType, resolve: {} },
589-
},
590-
});
591-
expect(() => inputObjType.getFields()).to.throw(
592-
'SomeInputObject.f field has a resolve property, but Input Types cannot define resolvers.',
593-
);
594-
});
595-
});
596-
597569
it('Deprecation reason is preserved on fields', () => {
598570
const inputObjType = new GraphQLInputObjectType({
599571
name: 'SomeInputObject',

src/type/definition.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,22 +1550,15 @@ function defineInputFieldMap(
15501550
config: Readonly<GraphQLInputObjectTypeConfig>,
15511551
): GraphQLInputFieldMap {
15521552
const fieldMap = resolveObjMapThunk(config.fields);
1553-
return mapValue(fieldMap, (fieldConfig, fieldName) => {
1554-
devAssert(
1555-
!('resolve' in fieldConfig),
1556-
`${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`,
1557-
);
1558-
1559-
return {
1560-
name: assertName(fieldName),
1561-
description: fieldConfig.description,
1562-
type: fieldConfig.type,
1563-
defaultValue: fieldConfig.defaultValue,
1564-
deprecationReason: fieldConfig.deprecationReason,
1565-
extensions: toObjMap(fieldConfig.extensions),
1566-
astNode: fieldConfig.astNode,
1567-
};
1568-
});
1553+
return mapValue(fieldMap, (fieldConfig, fieldName) => ({
1554+
name: assertName(fieldName),
1555+
description: fieldConfig.description,
1556+
type: fieldConfig.type,
1557+
defaultValue: fieldConfig.defaultValue,
1558+
deprecationReason: fieldConfig.deprecationReason,
1559+
extensions: toObjMap(fieldConfig.extensions),
1560+
astNode: fieldConfig.astNode,
1561+
}));
15691562
}
15701563

15711564
export interface GraphQLInputObjectTypeConfig {

0 commit comments

Comments
 (0)