question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
chargomecommented, Sep 22, 2020

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

1reaction
BryanPan342commented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interfaces and unions in GraphQL - AWS AppSync
The GraphQL type system supports Interfaces . An interface exposes a certain set of fields that a type must include to implement the...
Read more >
Are array types incorrect when generating React/Apollo hooks ...
I am wondering if arrays defined in graphql queries ...
Read more >
GraphQL Code Libraries, Tools and Services
A plugin based schema builder for creating code-first GraphQL schemas in ... Type-safe response objects: genqlient generates the right type for each query, ......
Read more >
Interface Type - Hot Chocolate v10
A single object can implement multiple interfaces and is not limited to just one. An interface in GraphQL consists of a collection of...
Read more >
Serverless GraphQL using with AWS and ent
For the present tutorial, we type "Todo", see the screenshot below, and click the "Create" button. Screenshot of creating a new AWS AppSync...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found