Zero to GraphQL in 30 Minutes - Steven Luscher

Поділитися
Вставка
  • Опубліковано 26 гру 2024

КОМЕНТАРІ • 123

  • @jeehooahn9114
    @jeehooahn9114 8 років тому +171

    1:23 python esp. django
    10:07 ruby esp. rails
    14:30 node esp. express

  • @khanetor
    @khanetor 8 років тому +14

    Amazing! The most clear demo about GraphQL I've ever seen!

  • @jeehooahn9114
    @jeehooahn9114 8 років тому +5

    perfect video. detailed yet high level too. concise and thorough. many use cases, clear voice and structure. 0 dislikes.

  • @woodm1979
    @woodm1979 7 років тому +5

    Good lord! What a stellar presentation. I'm a python guy, but it was the "node pulling from external rest APIs" section that blew my mind.

  • @socaldevlabs3242
    @socaldevlabs3242 8 років тому +4

    I watched this couple months ago, now watched it again. Great video about GraphQL, thanks Steven.

  • @heymauriciosoares
    @heymauriciosoares 8 років тому +29

    That was impressive... I really didn't know it was that easy to implement a graphql endpoint on top of an existing rest API endpoint.
    Great talk.

    • @andreivedovato
      @andreivedovato 6 років тому +1

      also made a dark cloud go away from my mind

  • @GirishMani
    @GirishMani 7 років тому +2

    Wonderful demo on GraphQL. Deserved a standing ovation. Was blown over by the optimization technique you explained in the last 3 minutes. Thank you for uploading this.

  • @rjxl8
    @rjxl8 6 років тому +1

    Best hands on guide to using graphql, learn a lot and was able to implement graphql into a project thank you

  • @user72974
    @user72974 7 років тому +4

    I like the Node.js plot twist at the end. Awesome demo.
    I'm starting to get interested in this tech because it looks like a nice way for a front end dev to be able to build something in React etc without a back end dev being needed to make custom endpoints. I can see from the video that it still falls victim to the n + 1 problem (loading 4 friends of the person when a custom endpoint could use SQL or the ORM to perform a join etc and bring that down to one query), so maybe it would be useful for prototyping, and then later on a back end dev could create efficient endpoints for what is needed.

    • @steveluscher
      @steveluscher  7 років тому +3

      That sounds about right to me. You can always switch out the implementation for a better one, while keeping the types and the overall shape of the API the same!

  • @lucas.n
    @lucas.n 7 років тому +20

    My theory is that the presenter is actually an AI by Facebook. It's humanly impossible to type all this code without a single syntax error! And to trick the audience into believing that it's actually an human, the IA even made a small mistake at 27:20.

    • @MaxiTB
      @MaxiTB 5 років тому

      Practice. If you repeat it enough, and only focus on those snippets, it's not that hard.

    • @christiandasilva3590
      @christiandasilva3590 5 років тому +1

      @@MaxiTB and a good keyboard :)

    • @solomiosisante5696
      @solomiosisante5696 4 роки тому

      haha. yup. but man the irony. you made a mistake at IA.

  •  8 років тому +6

    Amazing Steve! So well explained and very interesting!

  • @RaphaelRibas
    @RaphaelRibas 7 років тому +1

    Excellent video, super concrete and easy to understand even for me who wasn't familiar with graphql.

  • @VladyVeselinov
    @VladyVeselinov 8 років тому +1

    Holy shit, my mind just exploded... This is awesome, Steven! I'm a simple front-end dev, do you think I can start learning back-end stuff straight from Graphql? I have a bit of experience with Node and Express.

    • @steveluscher
      @steveluscher  8 років тому +2

      That sounds great! Make it all the way to the “Using a real data source” section of learngraphql.com and you should be well on your way.

    • @saffashujah6358
      @saffashujah6358 6 років тому

      link is broken. :(

  • @jeehooahn9114
    @jeehooahn9114 8 років тому +3

    THIS is what I needed. How to allow frontend apps using graphql to talk to a server side api app

  • @kk-si6fy
    @kk-si6fy 7 років тому +1

    Is the bar on the left is client side JS or servicer side JS? so one can pass a Query instead of a JSON from the client side JS?

    • @steveluscher
      @steveluscher  7 років тому

      All of the JavaScript code you see *written* in this demo is server side JS, but the browser-based tool that I use to test the server sends the GraphQL query that you type as a string to the server over the network. The GraphQL resolver on the server side receives and parses that string, then executes it according to your rules.
      That said, there's literally nothing stopping you from shipping the GraphQL resolver to the client and executing the query in the browser. That's mostly an academic exercise - only in rare cases would that be useful.

  • @JuanHerrera-lu1bc
    @JuanHerrera-lu1bc 7 років тому +1

    best 30 minutes of my day! thanks

  • @444fed
    @444fed 8 років тому +6

    What Atom extension are you using to get the bar on the left?

    • @steveluscher
      @steveluscher  8 років тому +6

      It's Nuclide! nuclide.io/

    • @444fed
      @444fed 8 років тому

      Cool, thanks.

  • @mogalful
    @mogalful 8 років тому +8

    Great talk. I assume you're using oh-my-zsh - what's the theme with the 3 arrows?

    • @steveluscher
      @steveluscher  8 років тому +10

      It's the Sorin theme from Prezto, actually!

    • @mogalful
      @mogalful 8 років тому +1

      Steven Luscher oh, alrighty, thanks!

  • @donsudduth
    @donsudduth 7 років тому +1

    Very good hands-on start! Thx!

  • @MrMassaraksh
    @MrMassaraksh 7 років тому +1

    2 questions! How to query that info in web app, and how your methods work in python, without self?

    • @steveluscher
      @steveluscher  7 років тому

      So, interestingly, the GraphiQL UI that you see in the video *is* a web app. It simply makes requests to an endpoint (in this particular case, /graphql/) with a URL param named ‘query.’ The value of that URL param is the full text of the GraphQL query.
      As for the lack of ‘self’ in my Python code, it's just bad Python style on my part. Where you would typically create an argument called ‘self’ I named it ‘root.’ The Graphene docs use ‘self’ in their examples.

  • @kmlroot
    @kmlroot 7 років тому +1

    Awesome explanation about GraphQL, thanks a lot.

  • @oekofreak
    @oekofreak 7 років тому +1

    Great talk, do you also have one about mutating the graphql objects?

    • @steveluscher
      @steveluscher  7 років тому

      I don't, but I like this tutorial: graphql.org/graphql-js/mutations-and-input-types/ It uses the new ‘buildSchema’ utility.

  • @ZanderXue
    @ZanderXue 5 років тому

    but how to use graphql+dataloader in express+mongodb+mongoose😔

  • @Zahnno
    @Zahnno 8 років тому +1

    Can it handle conditions? say if item has a status of banned, the query will never return the name of the item.

    • @steveluscher
      @steveluscher  8 років тому +2

      Certainly. Since your backend already knows whether a record is banned or not, your resolver can simply check if you're allowed to see it and return `null` in the event that you're not.

  • @LevBrie
    @LevBrie 8 років тому +1

    Awesome demo. Out of curiosity, what's your iterm setup? Love the arrows and the color scheme.

    • @steveluscher
      @steveluscher  8 років тому +3

      +Lev Brie I use the Sorin prompt theme from Prezto, and the Solarized Dark color scheme.

    • @LevBrie
      @LevBrie 8 років тому +1

      +Steven Luscher Awesome thanks Steven, I've actually been meaning to expand beyond my Oh-My-Zsh horizons and play around with Prezto. Perfect timing.

  • @anees257
    @anees257 8 років тому +2

    what is complete playlist link of series of tech talks at Facebook HQ on April 19 2016?

    • @steveluscher
      @steveluscher  8 років тому +4

      +Anees Khan There was one other, and you can watch it here: ua-cam.com/video/oPSuvaYmXBY/v-deo.html

    • @anees257
      @anees257 8 років тому +1

      +Steven Luscher good, i have watched , this one was too awesome, i'm still hungry for GrapQL and Relay talks if you have more please upload it somewhere, happy programming

    • @steveluscher
      @steveluscher  8 років тому +2

      +Anees Khan Watch these when you have time: facebook.github.io/relay/docs/videos.html#content

  • @ronneilcamara5071
    @ronneilcamara5071 7 років тому +2

    hi Steven. I've started reading about GraphQL. I'd like to know if GraphQL can be another source/point of failure since we're inserting it as compared to the told way which is client does a REST api call to a an API server. Now with GraphQL, what happens now is client sents a request to GraphQL server then GraphQL server sends a REST call to the API server. It now has more steps. I really haven't read much more about GraphQL so my assumptions maybe wrong. FYI, I would like to mention I'm coding in React. I also do code in nodejs.

    • @steveluscher
      @steveluscher  7 років тому +3

      To wrap a GraphQL API around an existing REST API can be inefficient, as you've noted. Ideally, the GraphQL field resolvers would be able to make calls into your data fetching abstraction directly, rather than to make a second hop through a REST API. However inefficient, the ‘REST wrapper’ example in this video is useful for two reasons: 1) it shows just how arbitrary the code backing a GraphQL type can be, and 2) it demonstrates how you can quickly prototype a GraphQL API by piggybacking atop your existing REST API. You can expend minimal effort to see if GraphQL is valuable to you before deciding to go all in!

    • @ronneilcamara5071
      @ronneilcamara5071 7 років тому +1

      Thanks a lot! Btw, I really enjoyed your video. :)

    • @LukePighetti
      @LukePighetti 6 років тому

      @@steveluscher Thank you for the fantastic talk, Steven. I wonder, is it common to provide a thin cache at the GraphQL server to reduce load on the REST api? It would seem like a reasonable and performant solution to bridge the gap between prototype and backend rewrites.

    • @steveluscher
      @steveluscher  6 років тому

      I would say that it's common to place a read-through cache between your GraphQL field resolvers and _any_ API, @@LukePighetti. Even when your GraphQL field resolvers talk to ‘native’ ORMs like Ruby on Rails' ActiveRecord directly you get same-request caching for free (guides.rubyonrails.org/association_basics.html#controlling-caching). I would encourage you to design your system in such a way that it's presumed that you'll be requesting the same objects from disparate parts of your code that don't talk to each other.

  • @bangonkali
    @bangonkali 8 років тому +2

    Awesome. It seems that the resolvers can also have some business logic embedded.

  • @khanetor
    @khanetor 8 років тому +2

    I wish to ask about the potential `n+1` problem when you want to query for "friends". Would that issues another query, or would it be smart enough to prefetch related fields?

    • @steveluscher
      @steveluscher  8 років тому +1

      Check out this comment for more discussion: ua-cam.com/video/UBGzsb2UkeY/v-deo.html&lc=z12pd3copxfff1ggc04cg3m4eu3aw5sygek.1475100408250462

    • @ruslantalpa
      @ruslantalpa 7 років тому +2

      You basically need to write very smart resolvers that inspect the AST or even roll out your own execution module. Dataloader helps only up to a point. A custom execution engine is what's happening here subzero.cloud where each graphql query, no matter how deep is a single SQL query

  • @woodm1979
    @woodm1979 7 років тому +1

    Ooooh, forgot to ask... What is the Atom package that is handling your javascript imports?

    • @steveluscher
      @steveluscher  7 років тому +5

      It's custom! Open up your snippets.cson and drop this in: gist.github.com/steveluscher/1d71dabb42e1a4a4145d9d61a35feb4f

    • @woodm1979
      @woodm1979 7 років тому

      Thank you so much! That's excellent.

  • @Bosslogq
    @Bosslogq 5 років тому

    In summary, GraphQL allows me to add a layer on top of my API to make it easier to fetch the data I actually need. It helps to avoid creating all these bespoke endpoints for different consumers which need different data from the same source. But, following example from the video, if I need to fetch not one, but 10 users and their friends (aka pagination) would it mean GraphQL is going to execute all() query to get friends on each of the user? Which means 10 API calls + 10 API calls to get friends = 20 API calls (or 1 API call to get initial 10 users + 10 calls to get their friends = 11 API calls) - if I do it with bespoke endpoint, I could write a bespoke query to get this data in 1 database query = 1 API call - how does (if at all) GraphQL could solve this problem?

    • @steveluscher
      @steveluscher  5 років тому +1

      There are two approaches that I know of. First, you can slightly defer the fetch in order to batch calls for the same resource across different parts of the query tree (see graphqlme.com/2017/12/09/n1-queries-no-more/). Secondly, since you have access to the query itself when resolving it you can make a query plan. For instance if you can see that the friends field is present as a subselection of user you can decide to include friends via a join in the database query that fetches each user (see github.com/graphql-dotnet/graphql-dotnet/issues/21).

  • @ashishjangid5201
    @ashishjangid5201 7 років тому +1

    Can someone tell me how he is able to use import here without any error?

    • @steveluscher
      @steveluscher  7 років тому

      This particular example uses Babel to be able to convert the import statement to something that can run on any version of node (see the GitHub repo for an example of how to set this up using babel-node - github.com/steveluscher/zero-to-graphql/blob/master/zero-node/package.json#L7) but starting in Node 8.5.0, you can start to use it natively (stackoverflow.com/a/37132668).

  • @pynchia4119
    @pynchia4119 6 років тому

    it doesn't say how the Person django model associates/is found. Nor it does say how field names are resolved since they are specified with underscore in the model but queried in camelCase

    • @steveluscher
      @steveluscher  6 років тому

      We use `Person.objects.get(id)` to get person models by ID - one of the arguments available on the `person` field in the GraphQL schema. Camel casing field names from Django model properties is how the Graphene library works by default. Check out the docs for the `ObjectType` for more! docs.graphene-python.org/en/latest/types/objecttypes/

  • @FajnyAleZaNiski
    @FajnyAleZaNiski 8 років тому +2

    Why nobody talks about resolve method implementation to cover all the GraphQL syntax? Without resolve GraphQL is empty - gives nothing in fact. You have to implement resolve method by yourself for each query type. There is no default method that handles all GraphQL syntax, I guess.

    • @steveluscher
      @steveluscher  8 років тому +3

      The `resolve()` method takes a source, args, context, and an info argument, and must return either a value conforming to the type of the field it's resolving, or a Promise that resolves to that value. You can inspect the types of the four arguments in detail here: github.com/graphql/graphql-js/blob/master/src/type/definition.js#L469-L486

    • @FajnyAleZaNiski
      @FajnyAleZaNiski 8 років тому +1

      but by default it returns nothing, not cover GraphQL syntax at all, you have to implement it, I guess
      this is not like you define data structure and you send query and you got exact result, if you don't implement resolve you have nothing, for simple data like return data[ i ] is simple but for more complex data like lists, groups and so on it is very hard to use

    • @FajnyAleZaNiski
      @FajnyAleZaNiski 8 років тому +2

      Also you have build bugs:
      - you depends on global babel-node instalation instead of this from node_modules/.bin
      - babel-node shouldn't be used for real I guess
      - you have to npm install first but README run script first
      - also there is problem with deprecated print

    • @steveluscher
      @steveluscher  8 років тому +1

      Thanks for finding those! If you have time to send a pull request on GitHub, that would be awesome.

    • @FajnyAleZaNiski
      @FajnyAleZaNiski 8 років тому

      will see, not promise, bug for babel-node is in package.json, any plans to make resolve automatic? more easy to use?

  • @jeffreysapitan
    @jeffreysapitan 7 років тому

    Hi Steven, good talk.
    regarding NodeJs (Express), i'm wondering if it will affect server since you requested multiple query/fetch?
    basically you will send one request to the end point (Express), but behind the scenes, the end point will fetch multiple times to the 'source' base on the query?
    Sorry, i'm just started exploring the GraphQL. This video help me start. Thanks! :)

    • @steveluscher
      @steveluscher  7 років тому

      Certainly yes, the NodeJS GraphQL example you see here makes multiple requests to the REST server, which is not ideal. That example shows the *flexibility* of the GraphQL executor, but you would almost always want to move the executor as close to your database API as possible so that you can make requests ‘on the metal,’ rather than by calling out to a REST server over the network.

  • @AaronRobertHoulihan
    @AaronRobertHoulihan 7 років тому

    Thank you, Steve. This was awesome!

  • @PierreMaoui
    @PierreMaoui 8 років тому +1

    Do someone knows what is this zsh theme ?

    • @steveluscher
      @steveluscher  8 років тому +3

      +Pierre Maoui I use the Sorin prompt theme from Prezto, and the Solarized Dark color scheme.

  • @andrewli4484
    @andrewli4484 7 років тому

    Would it be logical to build a REST API alongside a GraphQL API with Express, as in creating all the REST endpoints the "rerouting" GraphQL endpoints to those endpoints via resolvers? This way the app can take advantage of GraphQL while also offering users REST?

    • @steveluscher
      @steveluscher  7 років тому

      Sure! I would recommend that you colocate both implementations with the underlying model layer. For example, if whatever offers your REST API lives on a server that fetches data through X (eg. ActiveRecord, Redis, MongoDB), colocate the implementation of your GraphQL API similarly, and resolve data for the queried fields using that same X. It's possible to wrap your REST API in a GraphQL API, but preferable to wrap your GraphQL API around the same data API that your REST API wraps around.

  • @vishnutechbuddy3106
    @vishnutechbuddy3106 4 роки тому +1

    excellent

  • @voiceaddict
    @voiceaddict 7 років тому +1

    Man, this was an awesome demo. Where can I learn more?

    • @steveluscher
      @steveluscher  7 років тому +1

      I would start by downloading the examples at github.com/steveluscher/zero-to-graphql. After that, try to expose a small part of your own app's API through GraphQL!

    • @voiceaddict
      @voiceaddict 7 років тому +1

      Done deal, Steven! Thanks so much!

  • @kkpoon
    @kkpoon 8 років тому

    wow, great demo.
    which Atom plugin does the help in es6 typing import hello from "hello"?
    thanks

    • @steveluscher
      @steveluscher  8 років тому +3

      +K.K. POON Open up your snippets.cson and drop this in: gist.github.com/steveluscher/1d71dabb42e1a4a4145d9d61a35feb4f

    • @kkpoon
      @kkpoon 8 років тому +1

      +Steven Luscher Great, it does great help. thanks!!!!!!

  • @SelmanKahya
    @SelmanKahya 6 років тому +1

    great presentation 👍

    • @levimajor8477
      @levimajor8477 3 роки тому

      i guess I'm kinda randomly asking but does anyone know a good place to stream newly released tv shows online ?

    • @bostonmatias4800
      @bostonmatias4800 3 роки тому

      @Levi Major i would suggest FlixZone. You can find it by googling =)

    • @louisduncan9434
      @louisduncan9434 3 роки тому

      @Levi Major Lately I have been using FlixZone. Just search on google for it :)

  • @danielszabo9819
    @danielszabo9819 7 років тому +1

    Cool and Inspiring video with a very talented performer.

  • @still-dreaming
    @still-dreaming 7 років тому +1

    Awesome live coding demo!

  • @charlinhos0824
    @charlinhos0824 8 років тому +2

    Steve I see many of the viewers has raised interest by the themes you have used in your GraphQL talk, so do I, the atom theme it is pretty nice, How I can found it .. By the way .. nice talk !!

    • @steveluscher
      @steveluscher  8 років тому +3

      I use the Solarized color theme everywhere. ethanschoonover.com/solarized

  • @alex.sprite
    @alex.sprite 7 років тому +1

    Great video mate

  • @smickandily
    @smickandily 5 років тому +1

    someone please tell me how he deletes the word as he starts typing here, and can you do this in sublime? ua-cam.com/video/UBGzsb2UkeY/v-deo.html&t=509

    • @steveluscher
      @steveluscher  5 років тому

      It's kind of hard to see in the video but I think I was double clicking on each word to select it. Starting to type replaces it once it's selected.

  • @giancarlosisasi4137
    @giancarlosisasi4137 7 років тому +3

    one word:
    A-W-E-S-O-M-E

  • @infinityx678
    @infinityx678 7 років тому +1

    For those that want to code along, I made a small API in Node that'll serve up endpoints with data just like in this video. Find it here:
    github.com/mikedloss/zero-to-graphql-helper

    • @steveluscher
      @steveluscher  7 років тому

      Cool! Also, don't miss github.com/steveluscher/zero-to-graphql for more examples using other languages and frameworks.

  • @Mustafaismail22
    @Mustafaismail22 8 років тому +1

    Great talk

  • @IgorKostyuchenok
    @IgorKostyuchenok 7 років тому +1

    Mind-blowing!

  • @nickportokallidis
    @nickportokallidis 8 років тому +1

    Stunned!

  • @HandiSulyansah
    @HandiSulyansah 8 років тому +1

    thanks dude.

  • @rickfarina9835
    @rickfarina9835 7 років тому +2

    Dude, you're the shit... (that's a compliment) :)

  • @jurajcarnogursky8542
    @jurajcarnogursky8542 7 років тому

    Use GraphQL along with Microservices:
    Express: ua-cam.com/video/-XHN1T6r_R4/v-deo.html
    HapiJS: ua-cam.com/video/VWPVrJU2upw/v-deo.html

  • @RomualdBrunet
    @RomualdBrunet 8 років тому +2

    Kinda disappointed, I though this might go deeper in the model query itself (making only one SQL query, possibly only querying the requested fields)
    (I've only watched the django part)
    But thanks anyway :)

    • @denkomanceski4106
      @denkomanceski4106 8 років тому

      I thought its more like an ORM as well

    • @steveluscher
      @steveluscher  8 років тому +3

      There are certainly people thinking about ‘query planning’ - how to use the query to craft optimized queries that do the minimal amount of work possible. Start reading from here for more: graphql.org/blog/rest-api-graphql-wrapper/#query-planning-and-beyond

    • @denkomanceski4106
      @denkomanceski4106 8 років тому +1

      ***** Thanks ++

  • @carljayectin6727
    @carljayectin6727 8 років тому +1

    just wow!

  • @G_ADE234
    @G_ADE234 3 місяці тому

    Very nice🎉🎉❤

  • @brunohplemos
    @brunohplemos 8 років тому +1

    💙

  • @Arya88-r7x
    @Arya88-r7x 3 місяці тому

    🎉🎉🎉

  • @Quran19898
    @Quran19898 6 років тому +1

    intro ua-cam.com/video/M5LlBetzICo/v-deo.html

  • @Jason-eo7xo
    @Jason-eo7xo 8 років тому +1

    AWESOMESAUCE

  • @kazenohito7641
    @kazenohito7641 6 років тому +1

    Poor javascript, you installed a gem and looked at a django console, and called express logs django logs. JS gets no love. :-(

  • @luissullcanivedia1795
    @luissullcanivedia1795 6 років тому

    Hola😎🙋‍♂️👏🖐🖐👍