#Nested object in Args()
7 messages · Page 1 of 1 (latest)
I think it’s just ArgsType on the root one and InputType on the nested one
@ArgsType is for queries. @InputType is for mutations. Are you sending those objects off to a query or a mutation @brazen roost ?
query
Then you should be using ArgType.
That I know, but when you want to nest an object within Args object, you have to use InputType as of now. Maybe it's a bug and ArgsType should work on all levels?
import {
Args,
ArgsType,
Field,
InputType,
Query,
Resolver,
} from '@nestjs/graphql';
import GraphQLJSON from 'graphql-type-json';
@InputType() // Doesn't work with @ArgsType
export class Filter {
@Field(() => String) field!: string;
@Field(() => GraphQLJSON) value!: any;
}
@ArgsType()
export class GetCompaniesArgs {
@Field(() => Filter, { nullable: true }) filter?: Filter | null;
@Field(() => String, { nullable: true }) orderBy?: string | null;
// and other get companies arguments
}
@Resolver()
export class StatusResolver {
@Query(() => String)
status(@Args() args: GetCompaniesArgs): string {
return 'ok';
}
}
I was helping with that recently: #1038034977213915206 message
I'd say it is a bug.