我将Postgres和GraphQL和NestJS与TypeScript和typeORM一起使用
我的GraphQL查询是:
{ Product { name } }
但是在查询日志中,我看到生成的查询是:
SELECT "ProductEntity"."id" AS "ProductEntity_id", "ProductEntity"."name" AS "ProductEntity_name", "ProductEntity"."description" AS "ProductEntity_description", "ProductEntity"."price" AS "ProductEntity_price" FROM "product" "ProductEntity"
所以为什么不像下面这样?
SELECT "ProductEntity"."name" AS "ProductEntity_name", FROM "product" "ProductEntity"
请在下面找到产品解析器:
@Resolver('product') export class ProductResolver { constructor(private readonly productService: ProductService) {} @Query() async product() { return this.productService.getProducts(); } }
产品服务:
@Injectable()
export class ProductService {
constructor(
@InjectRepository(ProductEntity)
private readonly productRepository: Repository<ProductEntity>,
) {}
async getProducts() {
return await this.productRepository.find();
}
}
我将Postgres和GraphQL和NestJS与TypeScript和typeORM一起使用我的GraphQL查询是:{产品{名称}}但是在查询日志中,我看到生成的查询是:SELECT“ ...