typegql icon indicating copy to clipboard operation
typegql copied to clipboard

How to use mutation with array?

Open SergeEsmanovich opened this issue 6 years ago • 1 comments

I try

  @Mutation({type: Number, description: ''})
    public async addSkillsSwToProfile(skillsSwInputDto: [SkillsSwInputDto]): Promise<number> {
        return 1;
    }

and getting Error: @Type SavageWorlds.addSkillsSwToProfile(skillsSwInputDto <-------): Could not infer type of argument. Make sure to use native GraphQLInputType, native scalar like 'String' or class decorated with @InputObjectType

graphqlmastery.com writes use GraphQLList

SergeEsmanovich avatar Sep 18 '19 15:09 SergeEsmanovich

Hey,

typegql is not able to automatically infer array types. You'd need to decorate your argument skillsSwInputDto like @Arg({type: [SkillsSwInputDto]}) skillsSwInputDto: SkillsSwInputDto[])

pie6k avatar Dec 09 '19 15:12 pie6k