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

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024

ความคิดเห็น • 41

  • @L0RDeX
    @L0RDeX 2 ปีที่แล้ว

    Hey Leo, good to see you man! Cool stuff :)

  • @Whateverworksism
    @Whateverworksism 3 ปีที่แล้ว +2

    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 ปีที่แล้ว +3

    Damned, i learned so much with this video. Thanks a lot !

  • @romaghorjomeladze439
    @romaghorjomeladze439 9 หลายเดือนก่อน

    The best content. I love it 🤩

  • @Yanis1
    @Yanis1 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

    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 9 หลายเดือนก่อน

    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 ปีที่แล้ว +1

    I was not expecting the "resolver testing is kind of a bitch sometimes", came out of nowhere XD

  • @sohamnandi7526
    @sohamnandi7526 2 ปีที่แล้ว

    @Leo Roese how to use custom scalar in your setup? or how to integrate it with graphql-scalars

  • @mahendranath2504
    @mahendranath2504 3 ปีที่แล้ว

    Thank you so much 👍🏼🙏🎉

  • @omarhadid1815
    @omarhadid1815 3 ปีที่แล้ว

    it is great tutorial
    and very clear
    keep going

  • @muratasarslan2359
    @muratasarslan2359 3 ปีที่แล้ว +1

    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  3 ปีที่แล้ว

      It’s just to generate typings to be used with typescript

  • @romaghorjomeladze439
    @romaghorjomeladze439 9 หลายเดือนก่อน

    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.

  • @jensvanhulst
    @jensvanhulst 2 ปีที่แล้ว

    What a great tutorial !!!! Just learning GQL and it's awesome. Is this video
    part of series ?

    • @CodeDunks
      @CodeDunks  2 ปีที่แล้ว +1

      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.

  • @daneilgreaves
    @daneilgreaves 3 ปีที่แล้ว

    Great video man!

  • @MrEnsiferum77
    @MrEnsiferum77 2 ปีที่แล้ว

    U call also inject the services through context or datasources, like simple DI

  • @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 3 ปีที่แล้ว

    Wonderful! Will you be federating these schemas as well?

    • @CodeDunks
      @CodeDunks  3 ปีที่แล้ว

      Maybe if I ever get some free time but no plans as of right now. Thanks for watching!

  • @alchemistmd2422
    @alchemistmd2422 ปีที่แล้ว

    hey any prerequisites in understanding this video, ik react , js html and css

  • @enriquecordero6163
    @enriquecordero6163 3 ปีที่แล้ว

    Gracias por el video

  • @vlad6075
    @vlad6075 2 ปีที่แล้ว

    "i trust myself i think" xD

  • @juandavidblancovergara2279
    @juandavidblancovergara2279 3 ปีที่แล้ว

    this code not works for me "305: Module '"apollo-server"' has no exported member 'makeExecutableSchema'.
    1 import { gql, makeExecutableSchema } from 'apollo-server';"

    • @CodeDunks
      @CodeDunks  3 ปีที่แล้ว

      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 ปีที่แล้ว +2

      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

  • @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.

  • @wtak6379
    @wtak6379 3 ปีที่แล้ว

    you should defenitively checkout nexus graphql !!!

  • @tony-ma
    @tony-ma 3 ปีที่แล้ว +2

    so much boilerplates code...

    • @CodeDunks
      @CodeDunks  3 ปีที่แล้ว

      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 TH-camr. 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.