Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws-appsync] Code first object type implementation of multiple interfaces generates invalid graphql output #10479

Closed
chargome opened this issue Sep 22, 2020 · 5 comments · Fixed by #10481
Assignees
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p2

Comments

@chargome
Copy link

chargome commented Sep 22, 2020

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 Report

@chargome chargome added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 22, 2020
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Sep 22, 2020
@BryanPan342
Copy link
Contributor

Nice catch @chargome! Writing a fix right now.

@BryanPan342
Copy link
Contributor

@chargome out of curiosity, how has your experience with the code-first approach been so far?

@chargome
Copy link
Author

@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!

@BryanPan342
Copy link
Contributor

BryanPan342 commented Sep 22, 2020

@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

@chargome
Copy link
Author

@BryanPan342 cheers, that's what I needed ✌️

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Sep 22, 2020
@MrArnoldPalmer MrArnoldPalmer added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 26, 2020
@mergify mergify bot closed this as completed in #10481 Sep 30, 2020
mergify bot pushed a commit that referenced this issue Sep 30, 2020
Make the GraphQL Schema construct multiple interface implementation in the following manner:

```gql
type Object implements Interface1 & interface2 {
  ...
}
```

Fixes #10479

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants