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

TypeError: Cannot read property 'name' of undefined #7

Closed
capaj opened this issue May 4, 2018 · 1 comment
Closed

TypeError: Cannot read property 'name' of undefined #7

capaj opened this issue May 4, 2018 · 1 comment

Comments

@capaj
Copy link

capaj commented May 4, 2018

I wanted to try this out and with the code:

import {
  Type,
  Field,
  Mutation,
  String,
  Boolean,
  Int,
  makeSchema
} from 'graphql-typescript'

@Type class Query {
  constructor() {
    this.box = new Size()
  }
  @Field box : Size
}

@Type class Size {
  @Field height : Int = 0
  @Field width : Int = 0
  @Field length : Int = 0
}

const schema = makeSchema(Query, {types: [Size]})

console.log(schema)

I am getting this error:

TypeError: Cannot read property 'name' of undefined
    at Object.createProperty (/home/capaj/git_projects/graphql/gql-ts-sample-project/node_modules/graphql-typescript/src/services.ts:11:26)
    at Field (/home/capaj/git_projects/graphql/gql-ts-sample-project/node_modules/graphql-typescript/src/decorators/Field.ts:45:19)
    at DecorateProperty (/home/capaj/git_projects/graphql/gql-ts-sample-project/node_modules/reflect-metadata/Reflect.ts:1214:35)
    at Object.decorate (/home/capaj/git_projects/graphql/gql-ts-sample-project/node_modules/reflect-metadata/Reflect.ts:737:24)
    at __decorate (/home/capaj/git_projects/graphql/gql-ts-sample-project/server.ts:4:92)
    at /home/capaj/git_projects/graphql/gql-ts-sample-project/server.ts:15:10
    at Object.<anonymous> (/home/capaj/git_projects/graphql/gql-ts-sample-project/server.ts:11:7)
    at Module._compile (module.js:635:30)
    at Module.m._compile (/home/capaj/.nvm/versions/node/v8.9.3/lib/node_modules/ts-node/src/index.ts:403:23)
    at Module._extensions..js (module.js:646:10)
@capaj
Copy link
Author

capaj commented May 4, 2018

oh you have to target ES6 with your typescript compiler! Makes sense.

@capaj capaj closed this as completed May 4, 2018
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

1 participant