Type-graphql: maybe a bug: resolveType union wrong when return type class @ObjectType

Created on 22 Aug 2019  路  9Comments  路  Source: MichalLytek/type-graphql

Hi
i have a problem with union but problem has been solved by change

image

to

image

at first node query return empty object, but fixed bug by above 馃樂

image

{
  node(id: "VHJlZTo2NTc4NDI3NjUyNjcxMTcyNjA4") {
    ... on Tree {
      id
      version
    }
  }
}

Question Solved

All 9 comments

Maybe cuz in my class @ObjectType not placing a name 馃

Maybe cuz in my class @ObjectType not placing a name 馃

it's not

Once again - what is the problem? Can you show me your object type classes or create a minimal reproducible code example repository? :confused:

maybe my dictation not very right
let me say it again:
with code in img1, graphql server return "{"node":{}}" ( an empty object )
then i has changed to img2, graphql server return as expected
so i said "maybe a bug with returnType function"

I have created a repo: https://github.com/quaj/reproduce-bug-type-graphql
guess this bug come with typegoose, tested regular class then nothing happend

Query test:

{
  node(id: "5d5da8ace13a526cf80fc264") {
    ... on Tree {
      version
    }
  }
}

Case tested:
convert model to regular object with node.toObject() but can't fixes

Cannot reproduce:

# Write your query or mutation here
{
  node(id: "5d602b0caf25c15fa0f7fe67") {
    ... on Tree {
      version
    }
    ... on Repo {
      source_id
    }
  }
}
{
  "data": {
    "node": {
      "source_id": "test"
    }
  }
}

It will return node: {} when the returned type is not covered by the ... on fragment syntax for this type.

sorry my bad, at first i covered with fragment but it's fragement of Tree so it return not correct

dont know why but in my production code bug still happened but in reproduce code is not
image
image

i can't move all source of production to reproduce this bug
anyway problem solved to me

many thanks @19majkel94, sorry for taking your time

Ah sorry, wrong screenshot
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

limenutt picture limenutt  路  3Comments

MichalLytek picture MichalLytek  路  4Comments

MichalLytek picture MichalLytek  路  3Comments

robertchung97 picture robertchung97  路  3Comments

Asim13se picture Asim13se  路  3Comments