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

more info in the error messages #27

Open
capaj opened this issue May 22, 2018 · 2 comments
Open

more info in the error messages #27

capaj opened this issue May 22, 2018 · 2 comments

Comments

@capaj
Copy link
Contributor

capaj commented May 22, 2018

when I specify a field decorator such as this:

@ObjectType({ description: 'Simple product object type' })
class Product {
  @Field()
  async wow(): Promise<number> {
    return 10
  }
}

I get this error:

TypeError: undefined is not a promise
    at Promise (<anonymous>)
    at resolveType (/home/capaj/git_projects/tests/type-gql/node_modules/typegql/lib/index.js:227:24)
    at inferTypeOrThrow (/home/capaj/git_projects/tests/type-gql/node_modules/typegql/lib/index.js:389:12)
    at resolveRegisteredOrInferedType (/home/capaj/git_projects/tests/type-gql/node_modules/typegql/lib/index.js:607:12)
    at compileFieldConfig$$1 (/home/capaj/git_projects/tests/type-gql/node_modules/typegql/lib/index.js:625:24)
    at /home/capaj/git_projects/tests/type-gql/node_modules/typegql/lib/index.js:658:39
    at Array.forEach (<anonymous>)
    at getAllFields (/home/capaj/git_projects/tests/type-gql/node_modules/typegql/lib/index.js:653:25)
    at /home/capaj/git_projects/tests/type-gql/node_modules/typegql/lib/index.js:666:39
    at Array.forEach (<anonymous>)

Which is fine-you need to specify the type explicitly using {type: Number}, but would it be possible to maybe at least print out a name of the field and the name of the class?
It's quite hard to find where the error is coming from if I have just added many fields

@pie6k
Copy link
Collaborator

pie6k commented May 22, 2018

Do you use compileSchema function of typegql to compile schema that is using this type? It should perform validation and do exactly what you're asking here.

Giving good error messages is really important for library like this. I'd appreciate if you'd describe steps to reproduce getting your error.

@capaj
Copy link
Contributor Author

capaj commented May 22, 2018

I just have this very basic project set up and I try most of the things there: https://github.com/capaj/type-gql-with-binding-boilerplate

Our production project is way to complex for experimenting like that. You can see I compile it here: https://github.com/capaj/type-gql-with-binding-boilerplate/blob/3ad576184fbdf405cf4445f1340728d3064a0947/index.ts#L55

and I run it using https://github.com/capaj/type-gql-with-binding-boilerplate/blob/3ad576184fbdf405cf4445f1340728d3064a0947/package.json#L7

I don't have the async field there, but you can easily just copu paste this field in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants