GraphQL

Search API providesGraphQLquery API, currently for companies only. It has no filtering or sorting capabilities, but it is a convenient way of exploring company hierarchies.

GraphQL companies query takes a list of company IDs as an argument and set of projections to apply on companies with those IDs. Projections may include all regular company attributes, but in GraphQL company has fields describing relations within company hierarchy, that can also be queried. Relations are defined as connections inRelay format.

Currently, query nesting is limited to one level (e.g. one can query children and ancestors for given company, but not children's children or ancestors' roots), with following exceptions:

  • Query parent for ancestor:
             
{companies(ids:[1]){ancestors{edges{node{id{edges{node{id}}}}}}}}
  • Query children count for some relation
             
{companies(ids:[2]){children{edges{node{children{count}}}}兄弟姐妹{edges{node{children{count}}}}}}

Result fromgraph expressions sectionmay be achieved using following GraphQL query:

Fetch companies through GraphQL

             
POST/v3/graphql
             
Authorization:Bearer$ACCESS_TOKENContent-Type:application/graphql{companies(ids:[56789]){idcompany_namechildren{edges{node{idcompany_name}}}兄弟姐妹{edges{node{idcompany_name}}}}}
             
Content-Type:application/json; charset=UTF-8{"data":{"companies":[{"id":56789,"company_name":“BigCompany US",“孩子”:{"edges":[{"node":{"id":1111,"company_name":“BigCompany US East"}},{"node":{"id":2222,"company_name":“BigCompany US South"}},{"node":{"id":3333,"company_name":“BigCompany US West"}}]},"siblings":{"edges":[{"node":{"id":23456,"company_name":“BigCompany US Asia"}},{"node":{"id":45678,"company_name":“BigCompany US Australia"}},{"node":{"id":12345,"company_name":“BigCompany US Europe"}},{"node":{"id":34567,"company_name":“BigCompany US South America"}}]}}]},"errors":[]}

JSON-wrapped query

GraphQL API also accepts GraphQL queries wrapped as JSON. This is controlled byContent-Typeheader and to use JSON version, it needs to be set toContent-Type: application/jsonrather thanContent-Type: application/graphql(the latter will be parsed as raw GraphQL query).

After setting appropriate header, the payload should be regularGraphQL over JSON.

Fetch companies through GraphQL over JSON

             
POST/v3/graphql
             
Authorization:Bearer $ACCESS_TOKENContent-Type:application/json{"query":"query($id:Long!){companies(ids:[$id]){id,company_name}}","variables":{"id":12345}}
             
Content-Type:application/json{"data":{"companies":[{"id":12345,"company_name":"A Company"}]},"errors":[]}