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

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024

Комментарии • 41

  • @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 8 месяцев назад

    The best content. I love it 🤩

  • @L0RDeX
    @L0RDeX 2 года назад

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

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

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

  • @ahnav
    @ahnav 2 года назад +1

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

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

  • @omarhadid1815
    @omarhadid1815 3 года назад

    it is great tutorial
    and very clear
    keep going

  • @romaghorjomeladze439
    @romaghorjomeladze439 8 месяцев назад

    I think it would be great to add request validation, error handling and JWT authorisation in this example repo for more completeness

  • @daneilgreaves
    @daneilgreaves 3 года назад

    Great video man!

  • @mahendranath2504
    @mahendranath2504 3 года назад

    Thank you so much 👍🏼🙏🎉

  • @enriquecordero6163
    @enriquecordero6163 3 года назад

    Gracias por el video

  • @vlad6075
    @vlad6075 2 года назад

    "i trust myself i think" xD

  • @sohamnandi7526
    @sohamnandi7526 Год назад

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

  • @MrEnsiferum77
    @MrEnsiferum77 2 года назад

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

  • @romaghorjomeladze439
    @romaghorjomeladze439 8 месяцев назад

    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.

  • @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 года назад +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

  • @alchemistmd2422
    @alchemistmd2422 Год назад

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

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

  • @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';

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

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

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

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