1. 程式人生 > 其它 >graphql介面測試記錄

graphql介面測試記錄

Register an account:

https://devportal.prometheanproduct.com/ 點選 Create a myPromethean account

How to get the idToken from devui

  1. Accesshttps://devui.prometheanproduct.com/
  2. Input login email and password then click 'LOGIN TO MANGO'
  3. Open the Chrome Dev Tool (F12), and switch 'Console' Tab
  4. In the console, Enter 'JSON.parse(localStorage.getItem('promethean:jwt')).AuthenticationResult.IdToken' , then you can gen the idToken.

5. Take the Authorization to this location and you can get

Send Request from GraphQL Playground

playground url

dev local debug (default port is 4000, you can change it in the serverless command) Comment
mdm-portal https://devapi.prometheanproduct.com/mdm-portal/graphql http://127.0.0.1:4000/graphql
configuration https://devapi.prometheanproduct.com/configuration/graphql http://127.0.0.1:4000/graphql
integration https://devapi.prometheanproduct.com/integration/graphql This is Platform's project

x-api-key

local debug/dev
mdm-portal bv6d45mobai6lk31l9sw6s9argxn42x0x35j7jlt
configuration bv6d45mobai6lk31l9sw6s9argxn42x0x35j7jlt
integration y14v59tlgyczjp3encuc07ca6pnj4msj94mj53pp

Note: For other environment, you can login to the Panel Management, then get the x-api-key from Chrome dev tool.

Send Request

HTTP header
{
"Authorization":"Bearer XXX",   
"x-api-key": "bv6d45mobai6lk31l9sw6s9argxn42x0x35j7jlt",
"x-auth-organization-id": "60b63190-0832-88c0-d843-a6cda5c4eda9"
}

Note: XXX is the idToken which can get from section 1

Request Body
query Panels($searchPanelsInput: ISearchPanelsInput) {
  Panels(searchPanelsInput: $searchPanelsInput) {
    panels {
      name
      serialNumber
      model
      mainboardFirmware
      updateAvailable
      tagCount
      tags
      status
      connectivityTimestamp
      __typename
    }
    totalCount
    __typename
  }
}

Note:Please set the 'schema.polling.enable' with 'false' in the Settings of playground. Otherwise, the playground will send the request all the time and the server will occur 'Out of Memory' issue.

Refer this document

https://shimo.im/docs/TryYYtyj6xGhy3K8

介面測試地址:https://devapi.prometheanproduct.com/mdm-portal/graphql

宣告 歡迎轉載,但請保留文章原始出處:) 部落格園:https://www.cnblogs.com/chenxiaomeng/ 如出現轉載未宣告 將追究法律責任~謝謝合作