No video

GraphQL Microservice Setup with Apollo Server, Codegen, Prisma, Typescript, and PostgreSQL

  Рет қаралды 16,311

CodeDunks

CodeDunks

Күн бұрын

Setup a GraphQL microservice using libraries such as Apollo Server, Codegen, Prisma, Typescript, PostgreSQL.
Starter project github: github.com/leo...
Part 1 (this video) Finish github: github.com/leo...
Finished project github: github.com/leo...
Timestamps
0:00 Intro
2:00 Apollo server init
4:00 gql playground
6:21 structure setup
8:40 typeDefs
10:40 queries
14:10 schema
17:00 schema vs codefirst
18:15 codegen
25:30 setup postgresql
26:30 prisma
31:10 prisma migration
32:35 prisma studio
34:00 prisma integrate
44:20 mutations
52:54 unit testing mock prisma client

Пікірлер: 41
@Whateverworksism
@Whateverworksism 3 жыл бұрын
Sweet video Leo! A good building block to build something more complex and a very nice introduction to graphql servers with TS. Nicely done!
@koko0808008
@koko0808008 3 жыл бұрын
Damned, i learned so much with this video. Thanks a lot !
@romaghorjomeladze439
@romaghorjomeladze439 7 ай бұрын
The best content. I love it 🤩
@L0RDeX
@L0RDeX 2 жыл бұрын
Hey Leo, good to see you man! Cool stuff :)
@Yanis1
@Yanis1 3 жыл бұрын
Thank you very much for the content you are sharing. I’m fond of your videos; I never got the motivation to learn graphQL because of the whole new terminology to learn but now you got me motivated 😁
@CodeDunks
@CodeDunks 3 жыл бұрын
You got this!
@johnnydriesen7575
@johnnydriesen7575 2 жыл бұрын
One of the best vids on this topic I've seen in the last couple of months ! Very educational. Thanks for willing to share your knowledge, and your time & effort to create this vid. Do you (or smb else) maybe have any idea how to implement one-to-many and many-to-many relations ? And how about Authentication ?
@romaghorjomeladze439
@romaghorjomeladze439 7 ай бұрын
I think it would be great to add request validation, error handling and JWT authorisation in this example repo for more completeness
@ahnav
@ahnav 2 жыл бұрын
I was not expecting the "resolver testing is kind of a bitch sometimes", came out of nowhere XD
@CodeDunks
@CodeDunks 2 жыл бұрын
Lol my bad
@jensvanhulst
@jensvanhulst 2 жыл бұрын
What a great tutorial !!!! Just learning GQL and it's awesome. Is this video part of series ?
@CodeDunks
@CodeDunks 2 жыл бұрын
Hey Jens, thanks for the feedback! Unfortunately, this was just a quick one-off and is not part of a series. I do have some other graphql federation videos on my channel, however.
@omarhadid1815
@omarhadid1815 3 жыл бұрын
it is great tutorial and very clear keep going
@daneilgreaves
@daneilgreaves 3 жыл бұрын
Great video man!
@mahendranath2504
@mahendranath2504 3 жыл бұрын
Thank you so much 👍🏼🙏🎉
@MrEnsiferum77
@MrEnsiferum77 2 жыл бұрын
U call also inject the services through context or datasources, like simple DI
@romaghorjomeladze439
@romaghorjomeladze439 7 ай бұрын
there is a strange behaviour in the code. If you put console.log in for example resolver function or service, the api endpoint is not returning response. So if you put console.log in getAllBooks resolver function and run books query from playground, it won't return any response (it's spinning and response isn't returned). If you remove the console.log, than there won't be any issue.
@sohamnandi7526
@sohamnandi7526 Жыл бұрын
@Leo Roese how to use custom scalar in your setup? or how to integrate it with graphql-scalars
@enriquecordero6163
@enriquecordero6163 3 жыл бұрын
Gracias por el video
@alchemistmd2422
@alchemistmd2422 Жыл бұрын
hey any prerequisites in understanding this video, ik react , js html and css
@muratasarslan2359
@muratasarslan2359 2 жыл бұрын
Wonderful! Will you be federating these schemas as well?
@CodeDunks
@CodeDunks 2 жыл бұрын
Maybe if I ever get some free time but no plans as of right now. Thanks for watching!
@SmashieHC
@SmashieHC 3 жыл бұрын
I really like the theme you have for VsCode, which one is it? :) Overall great video and I learned a lot, big thanks!
@CodeDunks
@CodeDunks 3 жыл бұрын
I use the dracula soft theme
@SmashieHC
@SmashieHC 3 жыл бұрын
@@CodeDunks Thank you! I'm curently working on a project and was wondering if I could ask a few questions. Do you have discord maybe? Feel free to add me SlappTasken#8638
@CodeDunks
@CodeDunks 3 жыл бұрын
@@SmashieHC sure there is a discord server I just set up on my channel banner
@muratasarslan2359
@muratasarslan2359 2 жыл бұрын
Hey Leo, I just deleted generated graphql.ts file, and my server runs with no error. Moreover, query & mutation are working correctly. So, what's the use of codegenerator here actually?
@CodeDunks
@CodeDunks 2 жыл бұрын
It’s just to generate typings to be used with typescript
@vlad6075
@vlad6075 2 жыл бұрын
"i trust myself i think" xD
@juandavidblancovergara2279
@juandavidblancovergara2279 2 жыл бұрын
this code not works for me "305: Module '"apollo-server"' has no exported member 'makeExecutableSchema'. 1 import { gql, makeExecutableSchema } from 'apollo-server';"
@CodeDunks
@CodeDunks 2 жыл бұрын
Yeah seems there may have been a change in where it is imported from since when I made the video. www.apollographql.com/docs/apollo-server/migration/ You can do something like import { makeExecutableSchema } from '@graphql-tools/schema';
@basicduck
@basicduck 3 жыл бұрын
Why use Postgres over Mongo?
@CodeDunks
@CodeDunks 3 жыл бұрын
The reason for using Postgres over Mongo is due to MongoDB support being in early access for Prisma. www.prisma.io/docs/concepts/database-connectors/mongodb
@basicduck
@basicduck 3 жыл бұрын
@@CodeDunks That makes sense lol
@wtak6379
@wtak6379 2 жыл бұрын
you should defenitively checkout nexus graphql !!!
@jwickerszh
@jwickerszh 2 жыл бұрын
Cool, but you don't really use the codegen here, hence why you can't figure out how to type the resolver input. And generating the schema is a bit convoluted. I only played a little bit with graphql and codegen but I came up with this instead: - I split my code into modules src/ and in each i have : --- .gql which is a raw GQL schema (eg: type Foo { id:String! } type Query { fooById(id: String): Foo }) --- a resolvers.ts that implements the needed resolvers for that gql Codegen is setup so it picks up all the gql files, plus some necessary mappings for Prisma, like so: overwrite: true schema: "./src/**/*.gql" documents: null generates: src/generated/graphql.ts: config: useIndexSignature: true contextType: "../context#Context" maybeValue: "T | undefined | null" mappers: Foo: "@prisma/client#Foo as PrismaFoo" scalars: DateTime: Date plugins: - "typescript" - "typescript-resolvers" Note: contextType maps to context.ts where for example: export interface Context { prisma: PrismaClient } Then all you need to do in each of your resolver.ts is to use the generated Resolvers type import { Resolvers } from '../generated/graphql' export const resolvers: Resolvers = { Query: { fooById: (_parent, args, context) => { return context.prisma.foo.findUnique({ where: { id: args.id || undefined }, }) }, }, } Then in my server.ts i recursively load all the gql into a schema and make it executable with the merge of all resolvers. So in that workflow you first write a GQL file, run generate that gets your type, then you can write your resolver automatically typed by the Resolvers type.
@CodeDunks
@CodeDunks 2 жыл бұрын
Hey Jeremy, this is awesome! I also appreciate the feedback on this. I agree that after getting to play around with this setup some more that I could have made a lot of things in this video a little bit clearer like the things you mentioned in this comment.
@tony-ma
@tony-ma 2 жыл бұрын
so much boilerplates code...
@CodeDunks
@CodeDunks 2 жыл бұрын
I agree, was just trying to convey the typings for typescript but the tradeoffs are excessive haha.
@thehaystacker7965
@thehaystacker7965 2 жыл бұрын
In almost all his videos, what this guy actually does is copy and paste the code from other forums like medium or something which other people have written. This guy barely knows what's actually happening and we can clearly see that while he explains things. Just spotted another fake KZfaqr. This video too will be copied from somewhere else for sure !
@thahashahrod
@thahashahrod 2 жыл бұрын
Stop being a hater, you probably don't know anything yourself.
The Truth About GraphQL
12:06
Theo - t3․gg
Рет қаралды 97 М.
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 11 МЛН
👨‍🔧📐
00:43
Kan Andrey
Рет қаралды 10 МЛН
Comfortable 🤣 #comedy #funny
00:34
Micky Makeover
Рет қаралды 16 МЛН
SPILLED CHOCKY MILK PRANK ON BROTHER 😂 #shorts
00:12
Savage Vlogs
Рет қаралды 45 МЛН
Codegen: The good, the bad and the ugly
6:37
Matt Pocock
Рет қаралды 30 М.
GraphQL Crash Course
2:59:54
Laith Academy
Рет қаралды 41 М.
JWT Authentication Node.js Tutorial with GraphQL and React
3:04:08
Apollo Server GraphQL Resolvers for Beginners
20:43
Cooper Codes
Рет қаралды 4,2 М.
How to setup a GraphQL API with Apollo, Nexus and Prisma
1:16:39
Victor Iris
Рет қаралды 5 М.
MobX Tutorial with React and Typescript
35:53
CodeDunks
Рет қаралды 17 М.
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 11 МЛН