Type-GraphQL的参数错误-参数没有类型?

时间:2019-10-04 13:01:57

标签: node.js graphql-js type-graphql

我遇到此错误,但是不确定到底是什么错误,因为它与我创建的其他解析器遵循相同的格式。这是错误:

`Error: You need to provide explicit type for Resolver#`getMultipleSomething parameter #2

这是我的解析器:

@Resolver(() => Object)
export default class Resolver{
    constructor(
        private readonly service: Service
    ){}

    @Query(() => Object)
    async getSomething(@Arg('id') id : number) : Promise<Object>  {
        return await this.service.getSomething(id);
    }

    @Query(() => [Object])
    async getMultipleSomething(@Arg('page') page : number, @Arg('per_page') per_page : number, @Arg('stringArray') stringArray : string[])  {
        return await this.service.getSomethings(page, per_page, stringArray);
    }
}

1 个答案:

答案 0 :(得分:0)

尝试@Arg('stringArray', type => [string]) stringArray : string[])

参考:https://github.com/MichalLytek/type-graphql/issues/37#issuecomment-407664643