Этот курс научит вас создавать GraphQL API с нуля. Его преподает разработчик, имеющий более 3 лет опыта работы с GraphQL и работавший с ним в нескольких корпоративных компаниях. К концу этого ускоренного курса вы станете экспертом и узнаете больше чем 99% пользователей GraphQL. Этот курс направлен не только на то, чтобы научить вас GraphQL, но и на то, как правильно использовать его в реальном приложении. Я надеюсь, вам понравится это!
Мы будем изучать все с нуля, и поэтому вы можете начать новичком в GraphQL, чтобы пройти этот курс. Однако мы будем использовать JavaScript в качестве основного языка, и поэтому некоторые знания JS будут весьма кстати. Мы также подключим наш сервер к интерфейсу и будем использовать React в качестве клиента. Таким образом, любые знания о внешнем интерфейсе были бы не лишними.
Этот курс научит вас:
Что такое GraphQL
В чем преимущества GraphQL
Изучите терминологию GraphQL
Как построить сервер GraphQL
Принципы современного дизайна
Добавление аутентификации
Работа с Prisma v3 для взаимодействия с БД Postgres
Подключение GraphQL к клиенту
Повышение производительности за счет изучения проблемы n + 1 и ее решения с data loaders .
Посмотреть больше
Это пробный урок. Оформите подписку, чтобы получить доступ ко всем материалам курса. Премиум
Ограничение времени просмотра
Вы можете просматривать пробный урок только 10 минут. Получите полный доступ, чтобы смотреть без ограничений.
Udemy - одна из самых больших площадок в мире по доставке обучающего контента от разных авторов всего мира. Присутсвуют курсы практически на любую тему.
If a user with a different token tries to delete a post which doesn't belong to his userId - it will return a userErrors.
There is only one reason to create a separate logic is that you want to reveal a user the actual error. To my mind it's unnecessary.
Respect conciseness!
restored
hazartilirot
is this course a good start or should I pick something else I am just starting with graphql what do you suggest?
hazartilirot
restored
Have a go at watching it. It's more or less okay. See how it goes... Let's say it's not the worst course I've watched so far.
restored
hazartilirot
Oh cool thats great. Will trouble you for further advice once done xD
hazartilirot
In the 55-th lesson he assigns a @unique directive to userId and creates a new field profile with an optional Profile? type;
What's the point I can't get it? What does it mean an optional profile and why he says it's a one-to-many relationship if a user can basically have one profile only meaning it must be a one-to-one relationship! He doesn't explain anything... I've just started to listen to the lesson once again at the 0:23 he says ONE-TO-ONE relationship (logically it's correct). Then, I even decided to switch on subtitles since English is a foreign language for me. Nevertheless I clearly hear and now read he says WE WANT TO HAVE (I was dubious about initially for I'd been thinking he must have said WE WON'T HAVE - subtitles show the same as I hear.
Okay, uniqueness I get it. I went to the [docs](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/one-to-many-relations), found a piece of explanation:
> **Comparing one-to-one and one-to-many relations**
> In relational databases, the main difference between a 1-1 and a 1-n-relation is that in a 1-1-relation the foreign key must have a UNIQUE constraint defined on it.
There must be only one user id as a foreign key in a Profile.
What about Profile? How a profile might be undefined? If you create a user a profile is created simultaneously or do I miss something? ¯\_(ツ)_/¯
```
model User {
id Int @id @default(autoincrement())
emai String @unique
name String?
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
bio String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fileds: [userId], references: [id])
userId Int @unique
}
```
#update: While typing all of this, I went to the [docs](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/one-to-one-relations), now I see where the example is taken from
Well, I haven't seen the implementation in which a user exists, but a profile is optional. That's what confused me.
hazartilirot
Folks, I'm a bit shocked from the author! The main projects is quite advanced. If you're a newcomer I think it would be quite difficult to keep the pace. He jumps in to Postgres, GraphQL, Prisma, Typescript.
If you're a proficient developer give me a hand.... if you know....
In the 55-th lesson he assign a decorator @unique to userId and create a new field profile with an optional Profile? type;
What's the point I can't get it. What does it mean an optional profile and why he said it's a one-to-many relationship if a user can basically have one profile only meaning it must be a one-to-one relationship! He doesn't explain anything.... ¯\_(ツ)_/¯
model User {
id Int @id @default(autoincrement())
emai String @unique
name String?
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
bio String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fileds: [userId], references: [id])
userId Int @unique
}
hazartilirot
Well, as for 49-th lesson once again! We may use a CommonJS syntax regardless or TypeScript. You just need to rename a file's extension to .mjs or (if I'm not mistaken) to specify it in a webpack's configuration.
hazartilirot
For goodness sake, I spent half an hour dealing with an issue in 49-th lesson.
Here's a solution for Windows Users I've published in the author repo:
https://github.com/harblaith7/GraphQL-Course-Udemy/issues/1
hazartilirot
hazartilirot
Here's a docker-compose.yml file in case you don't want to use Heroku.
Actually, I can't figure out as to why the author creates a new file canUserMutatePost.ts.
All we need to know is
1) postId which is already implemented in postResolvers.ts
2) authorId who created the post the value of which we take from his JWT Token.
The rest Prisma (or a postgres to be exact ) will do for us. There can't be a post with an authorId who didn't create the post.
Therefore we change
await prisma.post.findUnique({ where: {id: +postId} })
to
await prisma.post.findFirst({ where: { AND: [{id: +postId }, {authorId: userId}] } })
If a user with a different token tries to delete a post which doesn't belong to his userId - it will return a userErrors.
There is only one reason to create a separate logic is that you want to reveal a user the actual error. To my mind it's unnecessary.
Respect conciseness!
What's the point I can't get it? What does it mean an optional profile and why he says it's a one-to-many relationship if a user can basically have one profile only meaning it must be a one-to-one relationship! He doesn't explain anything... I've just started to listen to the lesson once again at the 0:23 he says ONE-TO-ONE relationship (logically it's correct). Then, I even decided to switch on subtitles since English is a foreign language for me. Nevertheless I clearly hear and now read he says WE WANT TO HAVE (I was dubious about initially for I'd been thinking he must have said WE WON'T HAVE - subtitles show the same as I hear.
Okay, uniqueness I get it. I went to the [docs](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/one-to-many-relations), found a piece of explanation:
> **Comparing one-to-one and one-to-many relations**
> In relational databases, the main difference between a 1-1 and a 1-n-relation is that in a 1-1-relation the foreign key must have a UNIQUE constraint defined on it.
There must be only one user id as a foreign key in a Profile.
What about Profile? How a profile might be undefined? If you create a user a profile is created simultaneously or do I miss something? ¯\_(ツ)_/¯
```
model User {
id Int @id @default(autoincrement())
emai String @unique
name String?
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
bio String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fileds: [userId], references: [id])
userId Int @unique
}
```
#update: While typing all of this, I went to the [docs](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/one-to-one-relations), now I see where the example is taken from
Well, I haven't seen the implementation in which a user exists, but a profile is optional. That's what confused me.
If you're a proficient developer give me a hand.... if you know....
In the 55-th lesson he assign a decorator @unique to userId and create a new field profile with an optional Profile? type;
What's the point I can't get it. What does it mean an optional profile and why he said it's a one-to-many relationship if a user can basically have one profile only meaning it must be a one-to-one relationship! He doesn't explain anything.... ¯\_(ツ)_/¯
model User {
id Int @id @default(autoincrement())
emai String @unique
name String?
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
bio String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fileds: [userId], references: [id])
userId Int @unique
}
Here's a solution for Windows Users I've published in the author repo:
https://github.com/harblaith7/GraphQL-Course-Udemy/issues/1
https://github.com/harblaith7/GraphQL-Course-Udemy/issues/2