我正在尝试使用CMake Error: install(EXPORT "MyLibTargets" ...) includes target "MyLib" which requires target "absl_base" that is not in the export set.
CMake Error: install(EXPORT "MyLibTargets" ...) includes target "MyLib" which requires target "absl_strings" that is not in the export set.
CMake Error: install(EXPORT "MyLibTargets" ...) includes target "MyLib" which requires target "absl_str_format" that is not in the export set.
创建参数类型以通过GraphQL查询接受参数。我在说的type-graphql
是MongoDB's native NodeJS driver documentation上的选项的属性。
sort
如您所见,简单类型很好,但是当涉及到排序对象之类的东西时,我不确定如何进行操作。
NestJS implements a date scalar like so:
@ArgsType()
export class FindAllArgs implements FindOneOptions {
@Field(type => Int, { defaultValue: 0, description: 'Sets the limit of documents returned in the query.' })
@Min(0)
limit?: number;
// This is where the custom sort would go about.
@Field(type => SortScalar)
sort?: sortScalar;
@Field(type => Int, { defaultValue: 0, description: 'Set to skip N documents ahead in your query (useful for pagination).' })
@Min(0)
skip?: number;
}
即使在示例中,它也使用returnTypeFunction import { Scalar, CustomScalar } from '@nestjs/graphql';
import { Kind, ValueNode } from 'graphql';
@Scalar('Date', type => Date)
export class DateScalar implements CustomScalar<number, Date> {
description = 'Date custom scalar type';
parseValue(value: number): Date {
return new Date(value); // value from the client
}
serialize(value: Date): number {
return value.getTime(); // value sent to the client
}
parseLiteral(ast: ValueNode): Date {
if (ast.kind === Kind.INT) {
return new Date(ast.value);
}
return null;
}
}
。我应该将@Scalar('Date', type => Date)
替换为什么?我要为Date
,parseValue
和serialize
输入什么?
答案 0 :(得分:1)
您可以仅使用@InputType
将对象嵌套在args中-您不需要标量,它们仅用于可序列化的事物,例如时间戳->数字,mongo id-> ObjectId实例等。< / p>