Typescript GraphQL CRUD Tutorial

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

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

  • @raymondmichael4987
    @raymondmichael4987 5 лет назад +35

    Yes, please let's expand it bro.
    Nice pace and to the point.
    Greetings from Tanzania 🇹🇿

  • @chrispetten2473
    @chrispetten2473 5 лет назад +27

    Awesome video, would love to see more, especially how to add resolvers for relationships. Maybe something like movies to directors? Keep up the great work Ben. Also, I think we need to start calling you The Exorcist...because there are "nodemons".

  • @Sam-xv5ko
    @Sam-xv5ko 3 года назад

    I can see the smile on the face when saying I just created this CLI tool. This is kind of proud of myself that I want in my life.

  • @rallokkcaz
    @rallokkcaz 5 лет назад +6

    Ben! These videos are exactly what I wish I could tell people about modern JS/TS development. Thank you for spreading the word of sane JS developers.

  • @CayoFroes
    @CayoFroes 5 лет назад +1

    I spent the whole weekend searching and reading how to use typescript with graphql. After I finished it, you uploaded the video! Sad but happy.

  • @richdoan7769
    @richdoan7769 4 года назад

    If you are already familiar with GraphQL, Apollo, and Typescript, this is a good tutorial. If you're not, then it's not.

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

    Thank you for this introduction. I really appreciate how you take the time to explain the context of what you are doing. It's refreshing to have someone put those smaller contextual pieces together for me. You are awesome!

  • @md.akib5124
    @md.akib5124 5 лет назад +3

    I just simply love your way of creating js project ben.

    • @bawad
      @bawad  5 лет назад +2

      thanks

  • @ijazkhan3335
    @ijazkhan3335 5 лет назад +45

    The way you pronounced "nodemon" :D

    • @PROFjavi
      @PROFjavi 5 лет назад +2

      if the great Ben Awad pronounces Node Monitor as Node Demon, it makes him more human and gives me confidence in completing his tutorials. Don't change, Ben

    • @kyle7382
      @kyle7382 5 лет назад +1

      their icon is a devil/demon tho, I think he might be right

    • @PROFjavi
      @PROFjavi 5 лет назад +2

      Guess he's not human after all

    • @ijazkhan3335
      @ijazkhan3335 5 лет назад +1

      @@PROFjavi Yeah.. that's messed up lol

    • @mbembaships
      @mbembaships 4 года назад +1

      😂 I lost my shit 😂 too funny

  • @MrSnakeGGG
    @MrSnakeGGG 4 года назад

    Great video man!
    You really helped me to figure out how to make typegoose and type-graphql work together with this typeORM example.

  • @fabioramatis2373
    @fabioramatis2373 5 лет назад

    Awesome work! I knew your channel yesterday by config my vim setup and I love your content! I'm beginning with typescript because of you and I'm loving the benefits

  • @marcioferlan
    @marcioferlan 5 лет назад +10

    Good one, Ben! I really loved this video..
    Could you please add more features to it? Like simple auth handling, validation and entity relationships?

    • @bawad
      @bawad  5 лет назад +10

      sure

  • @reactivicky
    @reactivicky 4 года назад

    awesome video. We are using type-graphql in our company project now :)

  • @DaumChannelGamePart
    @DaumChannelGamePart 3 года назад +2

    If sqlite3 does not install properly, try installing version ^4.1.1 (Add "sqlite3": "^4.1.1" to dependencies of package.json.)

  • @-Jakob-
    @-Jakob- 5 лет назад +1

    There are also nice @ArgsType() and @Args decorators, using them you don't have to use an additional scope within your parameters and you can pick only some parameters you actually want to offer on your parameter definition and you also can set default values, example:
    @Args()
    {
    title = "default title",
    description = "default description",
    }: CreateEventArgs
    The parameter class (here named CreateEventArgs) is then decorated with @ArgsType() instead of @InputType()

    • @bawad
      @bawad  5 лет назад

      The one thing I don't like about that decorator is it's virtual, the graphql mutation wont take a object type but the individual args

  • @mehdiboujid8761
    @mehdiboujid8761 3 года назад +1

    i ve googled everywhere it s seems a lot of people having the same problem, yarn install throw an error related to sqlite3 (i am using wsl2)

  • @marlonmarcello
    @marlonmarcello 5 лет назад

    Great video Ben! You should extend this tutorial, would be great to see how you implement the frontend on top of it with typescript and how you deploy. Interested to know your preferences and your take on those.

    • @bawad
      @bawad  5 лет назад +1

      Checkout this for how to integrate with a react/next.js frontend ruclips.net/p/PLN3n1USn4xlkDk8vPVtgyGG3_1eXYPrW-

    • @bawad
      @bawad  5 лет назад +1

      also just added github.com/benawad/create-graphql-api#how-to-deploy-to-heroku

  • @everythingdivi6970
    @everythingdivi6970 4 года назад +2

    Thank you so much! Do you have a simple sequel on how to connect with react?

  • @ScottSpencePlease
    @ScottSpencePlease 5 лет назад +4

    This is DOPE!! Thanks for this Ben 🙏
    I've used Prisma in the past with GraphQL Yoga for the middle-wear and it was such a PITA for adding new fields and having to regenerate everything, this looks a lot more simplified!
    So, for me Ben, I'd like to know how to get this onto a sever somewhere, Zeit's now or something similar.

    • @bawad
      @bawad  5 лет назад +1

      sure thing

    • @bawad
      @bawad  5 лет назад +1

      Added a section on how to deploy: github.com/benawad/create-graphql-api#how-to-deploy-to-heroku

    • @ScottSpencePlease
      @ScottSpencePlease 5 лет назад

      wheeeeeeee! Thank @@bawad I'll have a play now!!

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

    Do you think graphql would work with unity? I am confused how we'll be able to send the query format,

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

    Can you make an updated version of this video? I wanna know what you changed after using this stack for a year.

  • @mertavsar5033
    @mertavsar5033 4 года назад +3

    Well explained. Thank you for the effort!

  • @superfunsurf
    @superfunsurf 4 года назад

    great stuff. yeah we want some expanded functionality for sure. thanks much and rock on.

  • @Trapezoideris
    @Trapezoideris 3 года назад +1

    Such a useful tutorial ben
    Thank you!

  • @skryonline5825
    @skryonline5825 4 года назад +1

    Loved it! Just perfect workflow. Similar to Nest.js

  • @qwerty01453
    @qwerty01453 5 лет назад +1

    Would love to see a video on graphql authentication!

    • @bawad
      @bawad  5 лет назад

      ruclips.net/video/25GS0MLT8JU/видео.html

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

    Thank you. It’s looking pretty cool. Is it possible to make a nested mutation? For example, if movies have an array of some tags, how to mutate them

  • @samibarasi1041
    @samibarasi1041 5 лет назад +1

    Very promising, but one problem I have with typeorm is, that it doesn't seem to give back any result if an update was successful or not. So how do you know if any row was affected by the update?

    • @bawad
      @bawad  5 лет назад

      Does it not return the rows affected?

    • @samibarasi1041
      @samibarasi1041 5 лет назад

      @@bawad No, it returns just empty arrays.

    • @bawad
      @bawad  5 лет назад

      I think the query builder might give you the rows affected typeorm.io/#/update-query-builder

  • @kps2642
    @kps2642 5 лет назад +2

    what do you think about prisma? I've been trying it out recently and I think it's pretty cool. Great vid as always

    • @danielfs
      @danielfs 5 лет назад

      Is it exclusive for graphql or can I use with just express?

    • @bawad
      @bawad  5 лет назад

      I like TypeORM better than Prisma v1, but I'm interested to give Prisma v2 a try when's it out and reevaluate

  • @prathamkesarkar
    @prathamkesarkar 5 лет назад +1

    Please make more videos on Type script + GraphQL

    • @bawad
      @bawad  5 лет назад

      You're in luck, I make a ton of typescript and GraphQL videos

  • @myhendry
    @myhendry 4 года назад

    Hi Ben, can i seek your advise? Im toying around with TypeGraphql unions and came across following statement... Be aware that when the query/mutation return type (or field type) is a union, we have to return a specific instance of the object type class. Otherwise, graphql-js will not be able to detect the underlying GraphQL type correctly when we use plain JS objects.
    What does it mean? Im able to get the TypeGrahql unions working using Graphql playground so i'm not sure where im supposed to return a specific instance of the object type class? and also what I need to do to return a specific instance of the object type class? Thanks

    • @bawad
      @bawad  4 года назад

      I would actually look at the resolveType option instead

    • @myhendry
      @myhendry 4 года назад

      @@bawad Noted Ben. Thanks

  • @chrispetten2473
    @chrispetten2473 5 лет назад

    I had a question about the dev dependencies. I noticed that in some of your previous projects that are structured very similarly to this one, you used @types/graphql. However, when I initialized the project that wasn't included, and it didn't seem to affect anything. Is there a reason for excluding/including @types/graphql? Are they included in type-graphql?

    • @bawad
      @bawad  5 лет назад +1

      @types/graphql is now included with the graphql package

  • @linuske
    @linuske 5 лет назад

    Hi Ben :) Congratulations, you're really insightful.
    Quick question though, is it possible to use ts-node-dev instead of Nodemon ?

  • @arpee1337
    @arpee1337 5 лет назад

    Hey Ben! What's you're setup to record these videos (screen casting/recording, green screen, camera, etc)?

    • @bawad
      @bawad  5 лет назад

      audio technica 2100 + canon eos sl2 + green screen + obs

  • @0916dhkim
    @0916dhkim 4 года назад

    I assume you handle db errors with standard try-catch?

  • @lamthaison2722
    @lamthaison2722 5 лет назад +1

    Bro!!! You always make awesome videos, i can’t stop checking ur chanel to make sure any new videos. By the way, would you like to teach online or have you had your own online course? I really want to purchase and learn from you

    • @bawad
      @bawad  5 лет назад +2

      No plans to do paid courses right now, focusing on free youtube courses and tuts

  • @nilmendes7710
    @nilmendes7710 5 лет назад

    Excellent tutorial, helped me a lot!
    Thanks for sharing your knowledge and time!
    Success in your projects!

  • @mertakbulut2541
    @mertakbulut2541 5 лет назад

    Suppose we have a table with 20 columns and 5 relationships. We would like to get 5 column and 1 relationship columns, with this example we took all of the columns data from table, return all of them. After than graphql picks and shows, is there a way to optimize the query ? Thanks for the video.

    • @bawad
      @bawad  5 лет назад

      yes
      1. you can read the info parameter in your resolver and determine the fields requested by the user, then optionally join tables
      2. you can use dataloader to optionally load relationships ruclips.net/user/results?search_query=benawad+dataloader

  • @RK-gm4pd
    @RK-gm4pd 5 лет назад +1

    why do you write script start exactly with --exec... It works for me just "nodemon index". Thank you

    • @fishamajig
      @fishamajig 5 лет назад +3

      Passing --exec tells nodemon to run a different program, instead of node. He's using ts-node as the executable since it's a TypeScript project. You can run and monitor other programs, such as python, ruby, etc. as well.

  • @abrahamvargas6818
    @abrahamvargas6818 4 года назад

    "message": "Connection \"default\" was not found.",
    why ?

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

    In Windows 10, when finished command 'npx create-graphql-api typescript-graphql-crud' and ran 'npm start', I got ''ts-node' is not recognized as an internal or external command,
    operable program or batch file.' What's wrong?

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

      You need to install ts-node. Do an `npm install` on the project if it still doesn't work try installing ts-node globally by running `npm i -g ts-node`

  • @EJIROEDWIN
    @EJIROEDWIN 4 года назад

    Basically, looks like in new ApolloServer the formatArgumentValidationError is not needed anymore as

  • @JoseAlvarez-lb6ng
    @JoseAlvarez-lb6ng 4 года назад

    Thx for the video learned a lot, do you know how to do mutations for entities with ManytoOne relations?

  • @oskioskioski
    @oskioskioski 5 лет назад

    I spent hours today trying to make this work with arrays of objects. Typeorm has decorators for ManyToOne() fields and handling relations, but I couldn't for the life of me get the data saved to (and loaded from) the database. Have you tried it? Any tips?

    • @bawad
      @bawad  5 лет назад

      ruclips.net/video/8kZ7W-bI5qQ/видео.html
      I think I'll be doing some more relationship videos soon

  • @petersantoso2605
    @petersantoso2605 5 лет назад

    hi Ben, thanks for the great tutorial..I have a question: is it possible to use optional parameter to query graphql? for example: with only Movie(title:string|null, length:string|null){} .. and will it return all rows if we dont pass any params : `{Movie{title length}}`..

    • @bawad
      @bawad  5 лет назад +1

      ! makes it non-null, so you can do title: String

    • @petersantoso2605
      @petersantoso2605 5 лет назад

      @@bawad thank you for the answer. btw your WOW-build site has some bug, content exceeds the box .Please consider to limit the title as well (replace with ...)

    • @bawad
      @bawad  5 лет назад

      thanks, do you have a link to the build that was overflowing?

    • @petersantoso2605
      @petersantoso2605 5 лет назад

      @@bawad this build filthy-casual-enhancement-shaman-talent-tree on the homepage

    • @bawad
      @bawad  5 лет назад +1

      thanks

  • @craigjohnson8279
    @craigjohnson8279 5 лет назад

    Great video Ben! Would you please do a follow up video on connecting this with React, TypeScript and @apollo/react-hooks?

    • @bawad
      @bawad  5 лет назад +1

      checkout how I do it in this video ruclips.net/video/25GS0MLT8JU/видео.html
      it's using different queries/mutations but the setup is the same

    • @craigjohnson8279
      @craigjohnson8279 5 лет назад

      @@bawad Awesome, thank you!

  • @jeanlikedenim
    @jeanlikedenim 5 лет назад

    Would love to see how you interstate subscriptions with this.
    And is there a better way to pass in resolvers into the buildSchema function. Example create a function that reads all the resolver files and return an array

    • @bawad
      @bawad  5 лет назад

      I might do a subscription template.
      typegraphql.ml/docs/bootstrap.html

  • @philippschmidt78
    @philippschmidt78 5 лет назад

    Any way you could showcase how to do all those CRUD operations via inheritance, both typeorm and type-graphql wise? So we don't have to implement them for every entity, but simply inherit all basic resolvers?

    • @philippschmidt78
      @philippschmidt78 5 лет назад

      And maybe also how to automatically get "edges" and "nodes" fields (connections?). I never understood how e.g. postgraphile creates those...

    • @bawad
      @bawad  5 лет назад +1

      I tried this once, but it was a pretty fragile abstraction and decided it wasn't worth it

  • @luebberteada
    @luebberteada 5 лет назад

    When wrapping app.listen in a function like that, how do we export the app variable to do endpoint testing with like supertest and jest?

    • @bawad
      @bawad  5 лет назад +1

      if you want to do that, I would do a named function and export it

  • @brzeczyszczykiewicz4476
    @brzeczyszczykiewicz4476 4 года назад +1

    Very good, thank you!

  • @dazzcelt
    @dazzcelt 4 года назад

    Any Plans to expand this Ben?

  • @mrbiditY
    @mrbiditY 5 лет назад

    Hey! Nice video as always! Could you do a video about robots.txt and sitemap? Would be super nice to see some of the best practices that you always deliver on those topics too! Keep up the good work!

    • @bawad
      @bawad  5 лет назад

      I actually never create sitemaps, and rarely use robots.txt.
      I'll sometimes stick a route in robots.txt if I don't want it picked up by google but that's about it

  • @DanishAnton
    @DanishAnton 5 лет назад

    This is great! Can you make a video about pushing a react app with graphql / typescript orm / postgres backend into production (ie. DigitalOcean, AWS, etc)?
    I also keep reading recommendations to run postgres as service to having to deal with backups, reliability, etc. Thoughts?

    • @bawad
      @bawad  5 лет назад

      github.com/benawad/create-graphql-api#how-to-deploy-to-heroku
      ruclips.net/video/AdHwBKKQHZ4/видео.html
      I think they are great if you want to trade money for less dev time.

  • @keithalleman9183
    @keithalleman9183 5 лет назад

    Any chance of doing unit testing for these using jest? Possibly with start to finish of any test util functions required?

    • @bawad
      @bawad  5 лет назад +1

      ruclips.net/video/fxYcbw56mbk/видео.html
      ruclips.net/video/zR8jKR9hnFA/видео.html

    • @keithalleman9183
      @keithalleman9183 5 лет назад +1

      @@bawad ​ I don't know how I missed that playlist, I had started a few of your other videos that were showing some testing but like mid way through when you already had multiple helper utils created and I felt overwhelmed jumping in, but this is definitely something I'm going to check out tonight and the video prior to it.

  • @manjime
    @manjime 5 лет назад

    Can you show how it integrates with class-validator, error handling and authorization in general?

    • @bawad
      @bawad  5 лет назад

      checkout ruclips.net/p/PLN3n1USn4xlma1bBu3Tloe4NyYn9Ko8Gs

  • @Soundtech98
    @Soundtech98 5 лет назад

    Hi Ben, nice to see more of these type-graphql videos. Quick question: I worked through the Type-GraphQL series and created a higher order resolver for the 'getAll' logic (ie. movies() ) I wonder if you could make a video addressing the where and orderBy selectors. I know Prisma auto-generates them for each entity, how might we do this with type-graphql? I found your response to stackoverflow.com/q/54192483/4411080 and that's essentially what I am looking to reproduce. That would be fantastic.

    • @bawad
      @bawad  5 лет назад

      I'm actually not sure how to do it without introducing a lot of complexity. Because you would need to iterate over all the fields in the entity and I don't know a simple way to do that.

  • @Petar-...-Nikov
    @Petar-...-Nikov 5 лет назад

    Great tutorial. Thank you!

  • @firmanjamal2871
    @firmanjamal2871 4 года назад

    Are you using Type-GraphQL for Saffron?

    • @bawad
      @bawad  4 года назад +1

      Yeah

  • @judeafam6441
    @judeafam6441 5 лет назад +1

    @ben awad, please can you do a react frontend for this? Thanks

    • @bawad
      @bawad  5 лет назад +1

      ruclips.net/p/PLN3n1USn4xlkDk8vPVtgyGG3_1eXYPrW-

  • @kevthatdevs3370
    @kevthatdevs3370 4 года назад

    Good stuff bro, I was wondering if you could do a similar video but hook it up to MongoDB and explain how the database gets updated under the hood?

    • @bawad
      @bawad  4 года назад

      I don't know mongo that well

  • @qbamc
    @qbamc 5 лет назад

    Im using the same but with mongoDb. Can you create a video about file upload ? lets say creating a user and uploading a profile picture in the same mutation. Thanks for your videos man.

    • @bawad
      @bawad  5 лет назад +1

      ruclips.net/video/s35EmAn9Zl8/видео.html

  • @temirzhanyussupov6997
    @temirzhanyussupov6997 5 лет назад

    Cool video liked it!

  • @anzo.p
    @anzo.p 4 года назад

    awesome!

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

    no-demon! I've been saying it wrong all along! LOL!

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

    Awesome

  • @tiagocunhafernandes6607
    @tiagocunhafernandes6607 5 лет назад

    Thanks, to Make this tutorial more complet you can add movies subscription

  • @malachitetrip830
    @malachitetrip830 5 лет назад

    Bro, can u create one video with graphical view of button combinations that u pressing, please?)

    • @bawad
      @bawad  5 лет назад

      benawad.com/vim
      ruclips.net/video/R2pBWDnfJY8/видео.html

    • @malachitetrip830
      @malachitetrip830 5 лет назад

      @@bawad Oh, bro, thx!)

  • @animeguy8547
    @animeguy8547 5 лет назад +2

    Can someone help me with how to do relations in resolvers and entities? Can't quite get it yet.

    • @bawad
      @bawad  5 лет назад

      ruclips.net/video/8kZ7W-bI5qQ/видео.html

  • @reynaldomarinho2
    @reynaldomarinho2 5 лет назад

    nice!

  • @Kprywatne
    @Kprywatne 5 лет назад

    what's up with the thumbnail? I noticed the last four/five videos you made yourself bigger and bigger. You feeling yourself more and more I see? XD

  • @MrBibou23ca
    @MrBibou23ca 5 лет назад

    Do someone knows how to create a live search bar with GraphQL using regex ?

    • @MrBibou23ca
      @MrBibou23ca 5 лет назад

      like the search in youtube or google

    • @bawad
      @bawad  5 лет назад

      What part of creating that are you unsure about?

    • @MrBibou23ca
      @MrBibou23ca 5 лет назад

      @@bawad The GraphQL Query structure

    • @MrBibou23ca
      @MrBibou23ca 5 лет назад

      Now I can get result only if I write the same name, saved in database. ex: if I search for "Car" , I should write it like it is, if I write "car" or just "ca" I get nothing !

    • @bawad
      @bawad  5 лет назад

      how are you doing the db query? You might want to try using the ilike operator

  • @royalbhati7837
    @royalbhati7837 5 лет назад

    That's node + mon = nodemon :p

  • @theemacsen1518
    @theemacsen1518 5 лет назад

    Hey Ben, have you ever tried using Oni vim?
    Its a GUI neovim and it seems pretty good
    github.com/onivim/oni

    • @bawad
      @bawad  5 лет назад

      I haven't, do you like it?

    • @theemacsen1518
      @theemacsen1518 5 лет назад

      @Ben Awad Yup, its amazing. I would definitely recommend it. Also since you are familiar with vim I would recommend using the minimal config that Oni has:
      github.com/onivim/oni/wiki/How-To:-Minimal-Oni-Configuration
      Here is how my Oni Vim looks like:
      imgur.com/F8i1kG4
      imgur.com/gallery/lhxaB8U

    • @bawad
      @bawad  5 лет назад

      cool, I'll have to give it a spin sometime

  • @naynyamish270
    @naynyamish270 4 года назад

    ts-node-dev is much better and faster than ts-node + nodemon

    • @bawad
      @bawad  4 года назад +1

      twitter.com/benawad/status/1211700652549779456

  • @aurangzaib5435
    @aurangzaib5435 5 лет назад

    Using typescript with graphql is not a good idea. Graphql is already strongly typed.

    • @bawad
      @bawad  5 лет назад +5

      I actually have the opposite opinion. Typescript is great with GraphQL *because* they are both strongly typed and you can share the types