Dear Ben Awad,
I'm also trying the code in your second lesson (register resolver TypeGraphql) and I went in two different issues.
One I solved, the other not yet.
Solved: createConnection() in typeorm is deprecated so I removed the ormconfig.json file and inserted in index.ts the following code:
and therefore the following to initialize the connection
const main = async () => {
await AppDataSource.initialize()
.then(() => {
// here you can start to work with your database
})
.catch((error) => console.log(error))
(....etc)
Everything is good. Query and mutation are working fine with the db but if I have still a problem with the variable 'name' as I get the following error "The 'parent' element is declared, but its value is never read.
Dear Ben Awad, I'm also trying the code in your second lesson (register resolver TypeGraphql) and I went in two different issues. One I solved, the other not yet. Solved: createConnection() in typeorm is deprecated so I removed the ormconfig.json file and inserted in index.ts the following code:
import { DataSource } from "typeorm" export const AppDataSource = new DataSource({ type: "postgres", host: "localhost", port: 5432, username: "postgres", password: "test", database: "nodedemo", synchronize: true, logging: true, entities: ["src/entity/."], subscribers: [], migrations: [], })
and therefore the following to initialize the connection
const main = async () => { await AppDataSource.initialize() .then(() => { // here you can start to work with your database }) .catch((error) => console.log(error))
(....etc)
Everything is good. Query and mutation are working fine with the db but if I have still a problem with the variable 'name' as I get the following error "The 'parent' element is declared, but its value is never read.
I used your code so that I have in Register.ts
@Resolver(User) export class RegisterResolver { @Query(() => String) async helloWorld() { return "Hello World!"; }
@FieldResolver() async name(@Root() parent: User) { return '${parent.firstName} ${parent.lastName}'; } (...etc...)
and in User.ts
@ObjectType() @Entity() export class User extends BaseEntity { @Field(() => ID) @PrimaryGeneratedColumn() id: number
}