Skip to content

Commit

Permalink
definition: replace object spread with explicit assignments
Browse files Browse the repository at this point in the history
In preparation for graphql#1527
  • Loading branch information
IvanGoncharov committed Aug 14, 2019
1 parent b113ef7 commit e04d92b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
37 changes: 34 additions & 3 deletions src/type/__tests__/definition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ describe('Type System: Objects', () => {
isDeprecated: true,
name: 'bar',
args: [],
astNode: undefined,
resolve: undefined,
subscribe: undefined,
description: undefined,
});
});

Expand All @@ -203,7 +207,17 @@ describe('Type System: Objects', () => {
}),
});
expect(objType.getFields()).to.deep.equal({
f: { name: 'f', type: ScalarType, args: [], isDeprecated: false },
f: {
name: 'f',
type: ScalarType,
args: [],
isDeprecated: false,
deprecationReason: undefined,
astNode: undefined,
resolve: undefined,
subscribe: undefined,
description: undefined,
},
});
});

Expand Down Expand Up @@ -233,6 +247,11 @@ describe('Type System: Objects', () => {
},
],
isDeprecated: false,
deprecationReason: undefined,
astNode: undefined,
resolve: undefined,
subscribe: undefined,
description: undefined,
},
});
});
Expand Down Expand Up @@ -625,7 +644,13 @@ describe('Type System: Input Objects', () => {
},
});
expect(inputObjType.getFields()).to.deep.equal({
f: { name: 'f', type: ScalarType },
f: {
name: 'f',
description: undefined,
type: ScalarType,
defaultValue: undefined,
astNode: undefined,
},
});
});

Expand All @@ -637,7 +662,13 @@ describe('Type System: Input Objects', () => {
}),
});
expect(inputObjType.getFields()).to.deep.equal({
f: { name: 'f', type: ScalarType },
f: {
name: 'f',
description: undefined,
type: ScalarType,
defaultValue: undefined,
astNode: undefined,
},
});
});

Expand Down
17 changes: 14 additions & 3 deletions src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,15 @@ function defineFieldMap<TSource, TContext>(
}));

return {
...fieldConfig,
isDeprecated: Boolean(fieldConfig.deprecationReason),
name: fieldName,
description: fieldConfig.description,
type: fieldConfig.type,
args,
resolve: fieldConfig.resolve,
subscribe: fieldConfig.subscribe,
isDeprecated: Boolean(fieldConfig.deprecationReason),
deprecationReason: fieldConfig.deprecationReason,
astNode: fieldConfig.astNode,
};
});
}
Expand Down Expand Up @@ -1368,7 +1373,13 @@ function defineInputFieldMap(
`${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`,
);

return { ...fieldConfig, name: fieldName };
return {
name: fieldName,
type: fieldConfig.type,
defaultValue: fieldConfig.defaultValue,
description: fieldConfig.description,
astNode: fieldConfig.astNode,
};
});
}

Expand Down

0 comments on commit e04d92b

Please sign in to comment.