fields defined on a third level and farther of function prototype chain are not registered into schema
capaj opened this issue · comments
I've got:
@ObjectType()
class TimestampedModel extends Model {
@Field({ type: GraphQLDateTime })
created_at: Date
@Field({ type: GraphQLDateTime })
updated_at: Date
}
@ObjectType({ description: 'Simple product object type' })
class Product extends TimestampedModel {
@Field({ type: String })
name: string
@Field({ type: Number })
price: number
@After(() => {
console.log('arguments', arguments)
})
@Field()
get wow(): number {
return 10
}
@Field() is_open: boolean
}
@ObjectType()
class UberProduct extends Product {
@Field({ type: String })
name2: string
}
@ObjectType()
class ExtraUberProduct extends UberProduct {
@Field({ type: String })
name3: string
}
@SchemaRoot()
class SuperSchema {
@Query({ type: String })
hello(name: string): boolean {
return false
}
@Query({ type: ExtraUberProduct, isNullable: false })
prod(): ExtraUberProduct {
const product = new ExtraUberProduct()
product.name = 'name'
product.price = 5
product.is_open = false
return product
}
}
const schema = compileSchema({ roots: [SuperSchema] })
console.log('schema: ', printSchema(schema))
the output is:
schema: type ExtraUberProduct {
name2: String
name3: String
}
type Query {
hello(name: String!): String
prod: ExtraUberProduct!
}
I expect it to be:
schema: type ExtraUberProduct {
created_at: DateTime
updated_at: DateTime
name: String
price: Float
wow: Float
is_open: Boolean
name2: String
name3: String
}
type Query {
hello(name: String!): String
prod: ExtraUberProduct!
}
BTW just for fun I've tried if this works in type-graphql library and it does.