I'm trying to make a mutation in type-graphql and one of the arguments is Object so:
@Mutation(() => Boolean)
async createProduct(
@Arg('name', () => String) name: string,
@Arg('price', () => Int) price: number,
@Arg('images', () => [InputImages]) images: [ImagesArray],
) {
// Code
}
So i made an input type for argument "images":
@InputType()
class InputImages {
@Field(() => String)
filename: string;
}
And an Object type:
@ObjectType()
export class ImagesArray {
@Field(() => String)
filename: string
}
Now i am trying to use GraphQL Code Generator and i need to write queries and mutations on client side as a .graphql file extension, so i have:
mutation CreateProduct(
$name: String!
$price: Int!
$images: [ImagesArray]!
) {
createProduct(
name: $name
price: $price
images: $images
);
}
And now when i try to run "npm run gen" says:
GraphQLDocumentError: Unknown type "ImagesArray".
I tried to add on top:
type ImagesArray {
filename: String
}
Does not work again, any idea?
ImagesArray
type in args:@Arg('images', () => [InputImages]) images: InputImages[],
mutation CreateProduct(
$name: String!
$price: Int!
$images: [InputImages!]!
) {
# ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.