Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with ASP.Net Core

59 views

Published on

GraphQL is a great way to expose your APIs and it has changed the way we think about consuming data over HTTP. With GraphQL we want to have one schema that provides all the data to us in a consistent way, enabling us to drill into the graph and fetch with one request what we actually want instead of having to issue multiple requests.
In the real world, however, we more often build small services that serve certain use cases. Simpler services are easier to maintain and can be deployed more rapidly. Moreover, we often also want to use external services that are not built by us. Ultimately, we will end up with multiple APIs again.
The solution for this dilemma is schema stitching. This talk will explore the schema stitching capabilities on ASP.Net Core with Hot Chocolate. We will show how you can set up a Hot Chocolate GraphQL gateway in under 5 minutes and move on to the various stitching scenarios.
This talk introduces simple auto-stitching scenarios and goes on to demonstrate how you can rewrite your GraphQL APIs into something truly new.

Published in: Education
  • Be the first to comment

  • Be the first to like this

.NET Fest 2019. Michael Staib. Hot Chocolate: GraphQL Schema Stitching with ASP.Net Core

  1. 1. GraphQL on ASP.NET Core WITH
  2. 2. Who are we?
  3. 3. Who is this for?Who is this for?
  4. 4. demo.chillicream.com
  5. 5. query { me { name age } } { "me": { "name": "Foo", "age": 99 } }
  6. 6. GET https://webservices.amazon.com/onca/xml? Service=AWSECommerceService& AWSAccessKeyId=mY-Sup3r-s3cr3!-k3y& AssociateTag=12345& Operation=ItemLookup& ItemId=0316067938& ResponseGroup=Reviews& TruncateReviewsAt=256& IncludeReviewsSummary=False& Version=2013-08-01& Timestamp=[YYYY-MM-DDThh:mm:ssZ]& Signature=[Request Signature]
  7. 7. What is GraphQL?
  8. 8. GraphQL No over- or under-fetching One Request Type System No versioning Simplicity One Endpoint Documentation Real-time Predictability
  9. 9. What GraphQL is not: • Graph database query language • Solution for binary streams • Facebooks version of OData • Bound to a specific data source • Limited to HTTP • Limited to the JavaScript world • A good solution for a health check endpoint.
  10. 10. REST GraphQL Shared Definition No Yes Conceptual Model Resources Graphs Organization Federated Centralized Related Ops Yes No Introspection No Yes Data Typing Weak Strong Real-Time No Yes
  11. 11. GraphQL Operations: • Query = Read • Mutation = Write • Subscription = Events
  12. 12. Demo
  13. 13. Resolvers and Pipelines
  14. 14. Demo
  15. 15. query { me { friends { friends { friends { name } } } } }
  16. 16. Demo
  17. 17. Scaling Your Graph
  18. 18. query { me { name age } }
  19. 19. query { me { name age friends { name age } } }
  20. 20. query { me { friends { friends { friends { name } } } } }
  21. 21. query { me { name stories(first: 10) { ... Content } } }
  22. 22. query { me { name stories(first: 10000) { ... Content } } }
  23. 23. type User { stories(first: PaginationAmount): [Story!]! } SchemaBuilder.New() .AddType(new PaginationAmountType(50)) ... .Create(); type User { stories(first: Int): [Story!]! }
  24. 24. type User { stories(first: PaginationAmount): [Story!]! @cost(complexity: 5) }
  25. 25. type User { stories(first: PaginationAmount): [Story!]! @cost(complexity: 5 multipliers:[first]) }
  26. 26. 1 1 50 me Stories(first: 10)name
  27. 27. 1 1 5000 me Stories(first: 1000)name
  28. 28. Demo
  29. 29. Persisted Queries
  30. 30. GraphQL Client GraphQL Server High Bandwidth Usage { "query" : <query> }
  31. 31. GraphQL Client GraphQL Server Unrestricted Query Execution { "query" : <query> }
  32. 32. GraphQL Client GraphQL Server Low Bandwidth Usage { “id” : “W5IYenw==” } Middleware
  33. 33. GraphQL Client GraphQL Server Restricted Query Execution { “id” : “W5IYenw==” } Middleware
  34. 34. Demo
  35. 35. Testing Your Schema
  36. 36. Demo
  37. 37. How can we do microservices with that?
  38. 38. What is schema stitching?
  39. 39. The capability to merge multiple GraphQL schemas into one schema.
  40. 40. Hot Chocolate Gateway Hot Chocolate GraphQL Mongo DBRaven DB Abritray REST Endpoint {REST} SQL Server query { me { messages { # Hot Chocolate GraphQL text # Apollo Server createdBy { name } # Abritray REST Endpoint views likes replies } } } One GraphQL Query Apollo GraphQL
  41. 41. Demo
  42. 42. Where do you find us? https://github.com/ChilliCream https://chillicream.com https://hotchocolate.io https://twitter.com/Chilli_Cream

×