Type-graphql: example for interface-inheritance does not work for implemented fragments

Created on 31 Jan 2020  路  4Comments  路  Source: MichalLytek/type-graphql

Describe the issue
the example interfaces-inheritance does not work as expected. When running the supplied graphql statements the fragments do not return the additional fields.

Tested on version 0.17 and 0.18.10-beta with no success.
steps to reproduce:

  1. start example/interfaces-inheritance server.
  2. run the supplied addStudent mutation.
  3. run the supplied persons query.
    image

what was expected:
both objects returned are Students, so should have their universityName field present.

code:
https://github.com/MichalLytek/type-graphql/blob/master/examples/interfaces-inheritance/examples.gql

I'm trying to implement the same thing in my own code base but having the same issue. I would really appreciate the update!

Duplicate

All 4 comments

AFAIK, it's related to #373. Could you confirm that that issue is about the same problem?

maybe not usefull, but i had the same problem (due to the orphanized type) and have solved it quit easy like this

@InterfaceType({
  resolveType: value => {
    return value.constructor.name;
  }
})
export abstract class IPerson implements IResource {

@MichalLytek confirmed, looks the solution presented here solved the issue. Thanks!

I've added the workaround to the examples in 801a453.
Maybe finding by value.constructor is better than instanceof check 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itsgracian picture itsgracian  路  3Comments

reilem picture reilem  路  3Comments

Tybot204 picture Tybot204  路  3Comments

MichalLytek picture MichalLytek  路  3Comments

tafelito picture tafelito  路  3Comments