Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraphQL vs Traditional Rest API [Devoxx Ukraine...

GraphQL vs Traditional Rest API [Devoxx Ukraine 2018]

What does GraphQL and Traditional REST API have in common? Shouldn't the GraphQL be connected to some graphs or similar? What is actually GraphQL all about?

Join me in this talk, while I try to answer all this questions and much more.

In this talk I will explain what GraphQL is, what are differences and similarities compared to more traditional REST API and show you this on working examples, since code worth more then words only ;)

Code:
https://github.com/vladimir-dejanovic/graphql-vs-traditional-rest-api-conftalk_demo
https://github.com/vladimir-dejanovic/graphql-spring-boot-example

Vladimir Dejanovic

November 24, 2018
Tweet

More Decks by Vladimir Dejanovic

Other Decks in Programming

Transcript

  1. @devoxxua @VladimirD_42 Simple Blog Author id name Post id title

    body authorId Comment id text postId authorId
  2. @devoxxua @VladimirD_42 Abuse of GraphQL query { allPosts { title

    comments { text createdBy { name posts { title comments { text
  3. @devoxxua @VladimirD_42 Abuse of GraphQL query { allPosts { title

    comments { text createdBy { name posts { title comments { text
  4. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  5. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  6. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  7. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  8. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  9. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  10. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  11. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  12. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  13. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  14. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  15. @devoxxua @VladimirD_42 public class GraphQLEntryPoint extends SimpleGraphQLServlet { @Override protected

    GraphQLContext createContext(Optional<HttpServletRequest> rq, Optional<HttpServletResponse> rp) { MyContext myContext = …. return myContext; } ……...
  16. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation
  17. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation
  18. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation
  19. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation
  20. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation
  21. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation
  22. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation
  23. @devoxxua @VladimirD_42 public class Query implements GraphQLQueryResolver { public List<Post>

    allPosts(DataFetchingEnvironment env) { MyContext myContext = env.getContext(); ………. Authentication & Authorisation