TypeGraphQL: metadataDesignType = отражениеType [parameterIndex] TypeError: Невозможно прочитать свойство '0' из неопределенного - PullRequest
2 голосов
/ 05 марта 2020

Я изучаю GraphQL с TypeGraphQL + Typescript. Это немного красиво, но у меня возникают проблемы с правилами набора.

Итак, у меня есть код ниже:

@Resolver(CountryInfo)
export class StaticDataResolver {

    @Query(_returns => [CountryInfo])
    allcountries(@Arg("arg") arg: string) {

        console.log(arg)
    }

    @Query(_returns => [CompleteCountryInfo])
    countryDetails(@Arg("countryId") countryId: string) {


        console.log(countryId)
    }

    @Query(_returns => [StateInfo])
    statesOfCountry(@Arg("countryId") countryId: string){


        console.log(countryId)
    }
}

Когда я запускаю сервер, я получаю ошибка:

F:\github\places-api\node_modules\type-graphql\dist\helpers\findType.js:10
        metadataDesignType = reflectedType[parameterIndex];
                                          ^
TypeError: Cannot read property '0' of undefined
    at Object.findType (F:\github\places-api\node_modules\type-graphql\dist\helpers\findType.js:10:43)
    at Object.getParamInfo (F:\github\places-api\node_modules\type-graphql\dist\helpers\params.js:9:49)
    at F:\github\places-api\node_modules\type-graphql\dist\decorators\Arg.js:9:159
    at F:\github\places-api\src\graphql\resolvers\static-data.resolver.ts:9:37
    at DecorateProperty (F:\github\places-api\node_modules\reflect-metadata\Reflect.js:553:33)
    at Object.decorate (F:\github\places-api\node_modules\reflect-metadata\Reflect.js:123:24)
    at __decorate (F:\github\places-api\src\graphql\resolvers\static-data.resolver.ts:4:92)
    at Object.<anonymous> (F:\github\places-api\src\graphql\resolvers\static-data.resolver.ts:12:5)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Module.m._compile (F:\github\places-api\node_modules\ts-node\src\index.ts:806:23)

Я не знаю, что не так с моим кодом, поэтому, если у кого-то есть ответ, это будет приветствоваться! =]

1 Ответ

0 голосов
/ 13 марта 2020

Похоже, вы используете babel без соответствующего плагина отражений метаданных TypeScript.

Пожалуйста, проверьте эту проблему: https://github.com/MichalLytek/type-graphql/issues/55

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...