Aws-cdk: [aws-appsync] Code first object type implementation of multiple interfaces generates invalid graphql output

Created on 22 Sep 2020  路  5Comments  路  Source: aws/aws-cdk


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 &.

Reproduction Steps


Given the following code:

const myInterface1 = new InterfaceType('MyInterface1', {
  definition: {
    // ...
  }
});

const myInterface2 = new InterfaceType('MyInterface2', {
  definition: {
    // ...
  }
});

const myObjectType = new ObjectType('MyObjectType', {
  interfaceTypes: [myInterface1, myInterface2],
  // ...
});

What did you expect to happen?

Output should be

interface MyInterface1 {
  # ...
}

interface MyInterface2 {
  # ...
}

type MyObjectType implements MyInterface1 & MyInterface2 {
  # ...
}

What actually happened?

Instead the code outputs the following, which is invalid graphql code:

interface MyInterface1 {
  # ...
}

interface MyInterface2 {
  # ...
}

type MyObjectType implements MyInterface1, MyInterface2 {
  # ...
}

Environment

  • CLI Version :
  • Framework Version: 1.63.0
  • Node.js Version:
  • OS :
  • Language (Version):

Other


This is :bug: Bug Report

@aws-cdaws-appsync bug efforsmall in-progress p2

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!

All 5 comments

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 鉁岋笍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artyom-melnikov picture artyom-melnikov  路  3Comments

kawamoto picture kawamoto  路  3Comments

PaulMaddox picture PaulMaddox  路  3Comments

eladb picture eladb  路  3Comments

nzspambot picture nzspambot  路  3Comments