nicolasdao / graphql-s2s

Add GraphQL Schema support for type inheritance, generic typing, metadata decoration. Transpile the enriched GraphQL string schema into the standard string schema understood by graphql.js and the Apollo server client.
Other
187 stars 15 forks source link

generate fields on concrete classes inherited from interfaces #24

Closed ryanmaxwell closed 5 years ago

ryanmaxwell commented 5 years ago

Hi,

I think it's great that if you use the inherits keyword, your subtype doesn't have to redeclare the fields that are already declared in the parent type.

It would be great if the compiler also did the same for interfaces. Currently the child types have to redeclare all the fields from an interface on all the implementing types. It's a lot of tedious boilerplate and this project would be perfect to remove it.

cheers

ryanmaxwell commented 5 years ago

are you kidding me, literally a minute after I file this bug you've bumped the version with this in it 😲

glennvgastel commented 5 years ago

PR #19 does indeed solve this. :) Let me know if something is still missing, I'll close the issue for now. ;)

ryanmaxwell commented 5 years ago

@Calcyfer sorry but i've tried out 0.17.2 and it's not inheriting the fields from an interface 🤔

basic example, the following typedefs are both prior and following compilation

interface Animal {
    name: String!
}
type Fish implements Animal {
    swimmingSpeed: Float
}
type Bird implements Animal {
    wingSpan: Float
}
glennvgastel commented 5 years ago

@ryanmaxwell Try it like this :

interface Animal {
    name: String!
}
type Fish implements Animal inherits Animal {
    swimmingSpeed: Float
}
type Bird implements Animal inherits Animal {
    wingSpan: Float
}
ryanmaxwell commented 5 years ago

ah ok so it's an opt-in by using the inherits keyword. Fair enough. Thanks and yes that does work!

glennvgastel commented 5 years ago

Indeed. Happy to hear it works! :)