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

ObjectType extends does not work #209

Closed
zuijiaoluo opened this issue Dec 3, 2018 · 5 comments
Closed

ObjectType extends does not work #209

zuijiaoluo opened this issue Dec 3, 2018 · 5 comments
Labels
Duplicate 🔑 This issue or pull request already exists Question ❔ Not future request, proposal or bug issue

Comments

@zuijiaoluo
Copy link

Describe the bug
I wanted to do a simple paging query, but found that ObjectType extends was not possible and the following error occurred, which would not have occurred without inheritance

To Reproduce
type.ts

@ObjectType()
export class PageInfo {
  @Field({ nullable: true })
  startCursor?: string;

  @Field({ nullable: true })
  endCursor?: string;

  @Field({ nullable: false })
  hasPreviousPage: boolean;

  @Field({ nullable: false })
  hasNextPage: boolean;

  @Field({ nullable: false })
  totalCount: number;
}

@ObjectType()
export class Connection {
  @Field({ nullable: true })
  pageInfo: PageInfo;
}
@ObjectType()
export class TextConnection extends Connection {
  @Field({ nullable: true })
  name: string;
}

resolver.ts

@Query(returns => TextConnection, { nullable: true })
  async Test() {
    return {
      pageInfo: {
        startCursor: 'string',
        endCursor: 'string',
        hasPreviousPage: true,
        hasNextPage: true,
        totalCount: 0,
      },
      name: "ok"
    };
  }

Expected behavior
just back true result

Logs
default

Enviorment (please complete the following information):

  • OS: mac
  • Node 8.9.1
  • Package version ^0.15.0
  • TypeScript version 3.1.6

Additional context
Add any other context about the problem here.

@MichalLytek
Copy link
Owner

Looks like a duplicate of #160 😕

@MichalLytek MichalLytek added Question ❔ Not future request, proposal or bug issue Need More Info 🤷‍♂️ Further information is requested labels Dec 3, 2018
@zuijiaoluo
Copy link
Author

What can I do? I want to help solve this problem.

@MichalLytek
Copy link
Owner

You have to wait 😞 #160 will be fixed by #183

@MichalLytek MichalLytek added Duplicate 🔑 This issue or pull request already exists and removed Need More Info 🤷‍♂️ Further information is requested labels Dec 3, 2018
@zuijiaoluo
Copy link
Author

Thank you. I'll wait for the new version, but I don't know how long it will take. Is there a temporary solution?

@MichalLytek
Copy link
Owner

Yes, you just need to return an instance of the class.
You can use a custom helper to be able to use plain objects - see #73 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🔑 This issue or pull request already exists Question ❔ Not future request, proposal or bug issue
Projects
None yet
Development

No branches or pull requests

2 participants