Using the code-first strategy: when an ObjectType implements several InterfaceType, the generated schema produces a syntax error since the interfaces are appended via , instead of &.
Given the following code:
const myInterface1 = new InterfaceType('MyInterface1', {
definition: {
// ...
}
});
const myInterface2 = new InterfaceType('MyInterface2', {
definition: {
// ...
}
});
const myObjectType = new ObjectType('MyObjectType', {
interfaceTypes: [myInterface1, myInterface2],
// ...
});
Output should be
interface MyInterface1 {
# ...
}
interface MyInterface2 {
# ...
}
type MyObjectType implements MyInterface1 & MyInterface2 {
# ...
}
Instead the code outputs the following, which is invalid graphql code:
interface MyInterface1 {
# ...
}
interface MyInterface2 {
# ...
}
type MyObjectType implements MyInterface1, MyInterface2 {
# ...
}
This is :bug: Bug Report
Nice catch @chargome! Writing a fix right now.
@chargome out of curiosity, how has your experience with the code-first approach been so far?
@BryanPan342 So far it has helped me a lot writing my (rather complex) GraphQL schema in a more modular and clear way. The only thing I am missing is the final schema output somewhere in my project, is there a straightforward way to do this? Good work!
@chargome glad to hear you have been having a good experience so far 馃槉
The only thing I am missing is the final schema output somewhere in my project, is there a straightforward way to do this?
check out this sample app i made!
It's not complete with functional resolvers at the moment, but I added a bit of code to cdk-app.ts to spit out the generated schema :)
https://github.com/BryanPan342/starwars-code-first/blob/master/bin/starwars-code-first.ts#L7-L20
@BryanPan342 cheers, that's what I needed 鉁岋笍
Most helpful comment
@BryanPan342 So far it has helped me a lot writing my (rather complex) GraphQL schema in a more modular and clear way. The only thing I am missing is the final schema output somewhere in my project, is there a straightforward way to do this? Good work!