Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

GraphQL Advanced

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
How to GraphQL
How to GraphQL
Chargement dans…3
×

Consultez-les par la suite

1 sur 44 Publicité

GraphQL Advanced

Télécharger pour lire hors ligne

Learn how to build advanced GraphQL queries, how to work with filters and patches and how to embed GraphQL in languages like Python and Java. These slides are the second set in our webinar series on GraphQL.

Learn how to build advanced GraphQL queries, how to work with filters and patches and how to embed GraphQL in languages like Python and Java. These slides are the second set in our webinar series on GraphQL.

Publicité
Publicité

Plus De Contenu Connexe

Diaporamas pour vous (20)

Similaire à GraphQL Advanced (20)

Publicité

Plus par LeanIX GmbH (20)

Plus récents (20)

Publicité

GraphQL Advanced

  1. 1. GRAPHQL ADVANCED LeanIX,  2017
  2. 2. What  you  will  learn 2 • Quick  recap  from  Part  1 • Deep  Dive:  Filter,  Paging,  Patches,  Revisions • How  to  embed  GraphQL in  Swagger,  curl,  Java • Concrete  use  case  (based  on  Python)
  3. 3. Recap  (1/3):  How  the  way  to  embed  LeanIX  is  evolving 3 Data  input ! Upload Web  UI Survey Data  usage Download Web  UI Mobile  App ITSM BPM Vendor  Lifecycles Metrics BPM ITSM Universe  of     modern  IT   management   tools Universe  of   modern   reporting   solutions Single   source  of   truth Out-­‐of-­‐ the-­‐box   inte-­‐ grations Integrated   information   hub "
  4. 4. Recap  (2/3):  Basic  Concepts  -­‐ Query  and  Mutation 4 query Retrieve  Fact  Sheet  data,   Subscriptions,  Tags,  …. mutation Create,  Update  or  Delete  Fact   Sheets,  Subscriptions,  Tags,  …
  5. 5. Recap (3/3): How to use the integrated GraphQL IDE from your LeanIX workspace 5 1 2 3 5 4 1 Access  GraphiQL from  the   admin  area 2 Use  auto-­‐completion  and   prettify  to  formulate  and  run   your  query 3 Optional:  Use  variables  to   better  structure  your  query 4 Access  the  results  directly,   iterate  until  you  have  got  all   data  you  need 5 Use  the  built-­‐in  reference    for   details
  6. 6. Advanced  Concepts:  Filter,  Paging,  Patches,  Revisions 6 Filter How to formulate your queries to get precisely your result? Paging How to query large  amounts of data in   productive settings? Patches How to leverage mutations for different  type   of changes? Revisions How to support a  stable productive environment with concurrent changes?
  7. 7. Advanced  Concepts:  Filter,  Paging,  Patches,  Revisions 7 Filter How to formulate your queries to get precisely your result? Paging How to query large  amounts of data in   productive settings?   Patches How to leverage mutations for different  type   of changes? Revisions How to support a  stable productive environment with concurrent changes?
  8. 8. 8 Filter:  Overview
  9. 9. Filter:  By  Fact  Sheet  IDs 9
  10. 10. Filter:  By  External  IDs 10 Pro  Tip:  Get  the   exact  Path  by   including  the   external  ID  in  the   results  and  using   autocomplete.
  11. 11. Filter:  By  exact  Display  Name 11 Attention:  There   are  different   display  name  rules   by  Fact  Sheet   types,  e.g.   including  hierarchy   or  release.
  12. 12. Filter:  By  Quick  Search 12 Attention:   Optimized  for   performance,   descriptions  etc.   are  not  included.
  13. 13. Filter:  By  Full  Text  Search 13
  14. 14. 14 Filter:  By  Filter  Facet
  15. 15. 15 Filter:  By  Filter  Facet
  16. 16. 16 Filter:  By  Filter  Facet
  17. 17. 17 Filter:  By  Filter  Facet
  18. 18. Pro  Tip:  Use  Browser  Developer  Tools  as  reference  for  Facet   Keys  and  Values   18 See  e.g.   https://developers.google.com/ web/tools/chrome-­‐devtools/ or   https://docs.microsoft.com/en-­‐ us/microsoft-­‐edge/devtools-­‐ guide
  19. 19. Advanced:  Use  a  subfilter (“show  all  applications  that  uses  an   IT  Component  of  Provider  Microsoft”) 19
  20. 20. Advanced:  Use  a  filter  on  relations  to  limit  the  result  set   (“show  all  applications  …  and  only  the  Microsoft  relations”) 20
  21. 21. Advanced  Concepts:  Filter,  Paging,  Patches,  Revisions 21 Filter How to formulate your queries to get precisely your result? Paging How to query large  amounts of data in   productive settings ? Patches How to leverage mutations for different  type   of changes? Revisions How to support a  stable productive environment with concurrent changes?
  22. 22. Paging:  Retrieve  large  amount  of  Fact  Sheets 22 1.  Include   pageinfo {}  in  your   query 2.  Obtain  a  cursor 3.  Use  “after”  with   the  cursor 4.  Repeat  until   “hasNextPages”  is   false
  23. 23. Advanced  Concepts:  Filter,  Paging,  Patches,  Revisions 23 Filter How to formulate your queries to get precisely your result? Paging How to query large  amounts of data in   productive settings?   Patches How to leverage mutations for different  type   of changes? Revisions How to support a  stable productive environment with concurrent changes?
  24. 24. Patches  Recap  (1/2):  Attributes 24 Use “validateOnly“  to test your query before executing it.
  25. 25. Patches  Recap  (2/2):  Relations 25 Learn more about patches in   Part  2  of the Webinar  Series.
  26. 26. Patches:  Summary 26 Operator Path Value • Add • Replace   • Remove A B C • /attributeName • /relationName/new_<idx>  for  new  relations • /relationName/<relationId>  for  existing  relations • String  for  attribute • JSON  Object  for  Relations  or  ExternalIDs • Array  for  Tag  /  Multi-­‐Select -­‐ It’s  always  good  practice  to  work  with  multiple  patches  in  one  API  call -­‐ Use  the  browser  developer  tools  as  reference  for  exact  syntax  if  unsure
  27. 27. Advanced  Concepts:  Filter,  Paging,  Patches,  Revisions 27 Filter How to formulate your queries to get precisely your result? Paging How to query large  amounts of data in   productive settings? Patches How to leverage mutations for different  type   of changes? Revisions How to support a  stable productive environment with concurrent changes?
  28. 28. 28 Revisions:  Clear  conflict  resolution  strategy 1.  Start  to  edit  a   Fact  Sheet  in  the   UI 2.  Retrieve  the   Fact  Sheet  via   GraphQL =>   revision:  23 3.  Update  the   Fact  Sheet  via   GraphQL =>   revision:  24 4.  Save  in  the  UI   – user  will  get  a   conflict
  29. 29. Embedding  GraphQL:  Beyond  the  inline  IDE 29 Swagger  /  curl How to call GraphQL via  REST Java Quick  Walkthrough Python Edit  application costs with GraphQL
  30. 30. Embedding  GraphQL:  Beyond  the  inline  IDE 30 Swagger  /  curl How to call GraphQL via  REST Java Quick  Walkthrough Python Edit  application costs with GraphQL
  31. 31. Embedding  GraphQL:  Call  GraphQL via  REST 31 Create  an  API  Token  before opening Swagger
  32. 32. Embedding  GraphQL:  Call  GraphQL via  REST 32 Insert  your API  Token  and press   „Explore“
  33. 33. 33 Embedding  GraphQL:  Call  GraphQL via  REST  -­‐ Query Insert  your Query  and press  „Try  it out“ Get your response Get the curl command.  See   https://dev.leanix. net/v4.0/docs/aut hentication as well.
  34. 34. 34 Embedding  GraphQL:  Call  GraphQL via  REST  -­‐ Mutation Insert  your Mutation  and press  „Try  it out“ Get your response Get the curl command.  See   https://dev.leanix. net/v4.0/docs/aut hentication as well.
  35. 35. Embedding  GraphQL:  Beyond  the  inline  IDE 35 Swagger  /  curl How to call GraphQL via  REST Java Quick  Walkthrough Python Edit  application costs with GraphQL
  36. 36. Embedding  GraphQL:  Call  GraphQL from  Java 36 1 2 3 4 1 Get  dependencies  via  Maven 2 Connection  with  help  of  SDK 3 Get  a  Fact  Sheet  (details  follow) 4 Update  a  Fact  Sheet  (details  follow) See  https://dev.leanix.net/v4.0/docs/graphql-­‐in-­‐java
  37. 37. Embedding  GraphQL:  Call  GraphQL from  Java  – Get  Fact  Sheet  By  Id 37 1 5 3 2 4 5 Use  an  abstract  base  class  for  efficiency1 Use  standard  JSON  libraries2 Build  the  query3 Execute  the  query4 Handle  errors
  38. 38. Embedding  GraphQL:  Call  GraphQL from  Java  – Update  Fact  Sheet   38 Same  base  class  as  before1 Create  the  required  patches2 Helper  method  to  handle  mutations3 1 2 3
  39. 39. Embedding  GraphQL:  Beyond  the  inline  IDE 39 Swagger  /  curl How to call GraphQL via  REST Java Quick  Walkthrough Python Edit  application costs with GraphQL
  40. 40. Embedding  GraphQL:  Editing  application  cost  in  Python   – Create  the  connection 40https://dev.leanix.net/v4.0/docs/graphql-­‐example-­‐application-­‐costs
  41. 41. Embedding  GraphQL:  Editing  application  cost  in  Python   – Initial  import 41 Use  https://pandas.pydata.org/ to  read  the  CSV1 Use  multiline  strings  to  represent  the  queries  /  mutations2 Use  Python  standard  JSON  processing  for  dealing  with   the  results 3 1 2 3
  42. 42. Embedding  GraphQL:  Editing  application  cost  in  Python   – Update 42 Use  https://pandas.pydata.org/ to  read  the  CSV1 Use  multiline  strings  to  represent  the  queries  /  mutations2 Use  Python  standard  JSON  processing  for  dealing  with   the  results 3 1 2 3
  43. 43. Summary:  What  you’ve  learnt  and  where  to  learn  more   43 What  have  you   learnt? Where  to  learn  more? Webinar  Part  3  – Custom  Reports • Advanced  concepts  (filter,  paging,  patches,  revisions) • How  to  embed  GraphQL (via  Swagger,  curl,  Java,  Python) A B C • Check  https://dev.leanix.net or  https://graphql.org • Reach  out  to  support@leanix.net for  feedback,  questions  and   ideas • Learn  how  to  upload  your  own  JavaScript  reports  based  on   GraphQL into  LeanIX
  44. 44. 44 “You  can’t  build  your  IT  architecture  today  with   yesterday’s  tools  and  stay  in  business  tomorrow”

×