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.

Support @Resolver without type name or class (code first)

See original GitHub issue

I’m submitting a…


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Application throw the following error when using @Resolver() without specifying any type name or type class:

  TypeError: Cannot read property 'prototype' of undefined

Caused by: https://github.com/nestjs/graphql/blob/master/lib/decorators/resolvers.decorators.ts#L250

Expected behavior

No error should be thrown.

Minimal reproduction of the problem with instructions

Sorry for my poor english, here is a test case to reproduce the issue: https://github.com/zhenwenc/nest-graphql-issues/blob/master/test/resolver-without-type-name.spec.ts

Environment


Nest version: 6.0.0


Issue Analytics

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

github_iconTop GitHub Comments

5reactions
itskemocommented, Aug 14, 2019

@zhenwenc I have happen to stumble upon the very same issue when using @ResolveProperty() decorator and what solved for me was to properly annotate the Resolver as per docs using Type not string name so for example in your case:

@Resolver('SampleObject')@Resolver(of => SampleObject)

So in your test simply change the annotation as specified above and all should work as expected.

Hope it helps! Tom

2reactions
kamilmysliwieccommented, Mar 18, 2019

Well, you’re right. Thanks for reminding me 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolvers - Apollo GraphQL Docs
We want to define resolvers for the numberSix and numberSeven fields of the root Query type so that they always return 6 and...
Read more >
Code-first vs. schema-first development in GraphQL
We review and compare the two approaches to creating a GraphQL service — code-first and schema-first — and take a stance on which...
Read more >
Resolvers | NestJS - A progressive Node.js framework
In the code first method, a resolver class both defines resolver ... indicate which class is the parent type (i.e., the corresponding ObjectType...
Read more >
Resolvers – GraphQL Tools
Writing resolvers with graphql-tools. ... Class Method Resolvers ... the type name as a string from __resolveType is only supported starting ...
Read more >
c# - Resolve Type from Class Name in a Different Assembly
Type.GetType("MyProject.Domain.Model." + myClassName);. This works great if the code that is performing this action is ...
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