GraphQL

Search API provides GraphQL query 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 in Relay 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
         parent {
           edges {
             node {
               id
             }
           }
         }
       }
     }
   }
 }
}
  • Query children count for some relation
{
 companies(ids: [2]) {
   children {
     edges {
       node {
         children {
           count
         }
       }
     }
   }
  siblings {
  edges {
       node {
         children {
           count
         }
       }
     }
   }
 }
}


JSON-wrapped query

GraphQL API also accepts GraphQL queries wrapped as JSON. This is controlled by Content-Type header and to use JSON version, it needs to be set to Content-Type: application/json rather than Content-Type: application/graphql (the latter will be parsed as raw GraphQL query).

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