prismake / typegql

Create GraphQL schema with TypeScript classes.
https://prismake.github.io/typegql/
MIT License
423 stars 21 forks source link

how to import Before and After decorators? #25

Closed capaj closed 6 years ago

capaj commented 6 years ago

we tried with @ivacko to import Before and After hooks, but we weren't able to run the code.

We tried both:

import { Before } from 'typegql/types/domains'
import { Before } from 'typegql'

in the first case:

Error: Cannot find module 'typegql/types/domains'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.wrappedResolveFilename [as _resolveFilename] (/home/capaj/git_projects/looop/project-alpha/back-end/node_modules/newrelic/lib/shimmer.js:326:39)
    at Function.Module._load (module.js:466:25)
    at Function.wrappedLoad [as _load] (/home/capaj/git_projects/looop/project-alpha/back-end/node_modules/newrelic/lib/shimmer.js:332:38)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/capaj/git_projects/looop/project-alpha/back-end/src/gql/commonSchema.ts:22:19)
    at Module._compile (module.js:635:30)
    at Module.m._compile (/tmp/ts-node-dev-hook-68135323187724.js:44:25)
    at Module._extensions..js (module.js:646:10)
    at require.extensions.(anonymous function) (/tmp/ts-node-dev-hook-68135323187724.js:46:14)
    at Object.nodeDevHook [as .ts] (/home/capaj/git_projects/looop/project-alpha/back-end/node_modules/ts-node-dev/lib/hook.js:61:7)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.wrappedLoad [as _load] (/home/capaj/git_projects/looop/project-alpha/back-end/node_modules/newrelic/lib/shimmer.js:332:38)

in the second:

TypeError: typegql_2.Before is not a function
    at Object.<anonymous> (/home/capaj/git_projects/looop/project-alpha/back-end/src/gql/commonSchema.ts:55:15)
    at Module._compile (module.js:635:30)
    at Module.m._compile (/tmp/ts-node-dev-hook-68135323187724.js:44:25)
    at Module._extensions..js (module.js:646:10)
    at require.extensions.(anonymous function) (/tmp/ts-node-dev-hook-68135323187724.js:46:14)
    at Object.nodeDevHook [as .ts] (/home/capaj/git_projects/looop/project-alpha/back-end/node_modules/ts-node-dev/lib/hook.js:61:7)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.wrappedLoad [as _load] (/home/capaj/git_projects/looop/project-alpha/back-end/node_modules/newrelic/lib/shimmer.js:332:38)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/capaj/git_projects/looop/project-alpha/back-end/src/gql/studentSchema.ts:13:24)
    at Module._compile (module.js:635:30)
    at Module.m._compile (/tmp/ts-node-dev-hook-68135323187724.js:44:25)
    at Module._extensions..js (module.js:646:10)

How are you supposed to import it?

Note that we have

  "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
pie6k commented 6 years ago

I'll take a look at this tomorrow morning as I'm out of home now.

pie6k commented 6 years ago

@capaj @Ivacko I've pushed new version to npm (0.5.1) that should solve this issue. Please let me know if it's working for you after updating.

pie6k commented 6 years ago

I'm closing it for now, let me know if it's still not resolved so I'll re-open.

capaj commented 6 years ago

works in 0.5.3 :+1: