Extend interfaces when extending schemas
See original GitHub issueHi!
I just realised that if you extend a schema, e.g.
const WorkspaceSchema = Joi.object({
statistics:Joi.object({
views: Joi.number()
})
}).label('IWorkspace')
const ProjectSchema = WorkspaceSchema.keys({
statistics:Joi.object({
users:Joi.number()
})
}).label('IProject')
You end up with two interfaces:
export interface IWorkspace {
statistics: {
views: number;
};
}
and
export interface IProject {
statistics: {
users: number
}
}
Wouldn’t it make more sense to extend IProject with IWorkspace?
export interface IProject extends IWorkspace {
statistics: {
users: number
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Interface extends multiple interfaces in GraphQL Schema
The answer to this question when it was asked was No, it is not possible for interfaces to extend (or implement) other interfaces....
Read more >Extending GraphQL: Part 2 - Types and Interfaces
After successfully creating a field with arguments and context, we are going to have a look at types and interfaces in GraphQL and...
Read more >Interfaces and inheritance - TypeGraphQL
The main idea of TypeGraphQL is to create GraphQL types based on TypeScript classes. In object-oriented programming it is common to create interfaces...
Read more >How to Extend the Schema - Win32 apps | Microsoft Learn
Determine the method of extension. Once you have carefully designed your schema changes, the next step is to decide which method to use...
Read more >Extending generated schema types · Issue #592 - GitHub
Hi, Is it possible to use the type for specific schemas and extend them? For example... Part of a generated file interface components ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have found in Joi where the data is, and modifying a test to be able to cover an implementation will be easy, because you already test concat. However, I cannot figure out where you write out the actual
export interface Foo
it should just be able to write out
export interface CombinedRecord extends Value, Metadata, Key
All the other logic is already in place for having properly created the interface. I’m just trudging through the code and have a rather difficult time interpreting where that work is being done.
That would be nicer, I’m not sure if Joi exposes this type of information, but this can be investigated