Rebuilding schema results in failure due to default value analysis #787
Labels
Bug 🐛
Something isn't working
Community 👨👧
Something initiated by a community
Solved ✔️
The issue has been solved
Milestone
Describe the Bug
When
buildSchema
has been called once, future calls result in an exception being thrown due to default value conflicts. Examples of the error are:To Reproduce
The root cause seems to be a
= new Date()
initializer in the target class. As a new instance of the class is constructed during schema generation, to retrieve default values from the class instance, the second call has a more recent timestamp.This also affects other cases where a complex default object is assigned with
x = new Complex()
in the class.I created a full repro at https://github.com/oliversalzburg/double-build-repro
Expected Behavior
buildSchema
calls should be idempotent.Additionally, assigning a default value in the graph through this mechanism wasn't intentional. It was purely meant as a measure to initialize locally constructed instances of that class.
Environment (please complete the following information):
Additional Context
type-graphql/src/schema/schema-generator.ts
Line 498 in 73736e2
The text was updated successfully, but these errors were encountered: