GraphQL Explorer

GraphiQL is a handy tool integrated into SensaAI that simplifies the process of accessing and understanding the data available through the site's GraphQL API.


Access to GraphQL Explorer

Please access the SensaAI GraphQL explorer here:

GraphQL Explorer

Key Features

The key features of the GraphQL explorer include:

  • Query Editor: You'll find a user-friendly query editor where you can compose your queries, mutations, and subscriptions. The editor helps you by offering suggestions as you type, highlighting syntax, and alerting you to any errors in your queries.
  • Documentation Explorer: The GraphQL explorer includes a sidebar that acts as your guide. It shows you the structure of the API, including available data types, queries, mutations, and their respective fields and arguments. This documentation helps you discover what's possible and what data you can request.
  • Autocompletion: As you start typing, GraphiQL provides you with intelligent suggestions based on the API's schema. This autocomplete feature speeds up your query construction by suggesting field names, arguments, and data types.
  • Query Execution: You can easily execute your GraphQL queries within the interface. Once you run a query, the results are displayed next to the editor, allowing you to inspect the data returned by the API.
  • Query History: If you've previously run queries, you'll find a history feature that lets you revisit and rerun them without needing to retype everything.
  • Error Handling: If there are any issues with your query, GraphiQL will point them out clearly, making it easier for you to correct and resubmit.

Whether you're simply exploring the available data or you have specific tasks in mind, GraphiQL on SensaAI makes interacting with the GraphQL API intuitive and efficient. It's a valuable resource to access and make the most of the data provided by our GraphQL API.

Using the GraphiQL Explorer

Access the SensaAI GraphiQL explorer here. Then, follow the configuration steps below.

Configuring the GraphiQL Explorer

  1. Retrieve your API access key.
  2. Launch the GraphiQL explorer.
  3. Below the query editor area click Header.
  4. Add your API access key as a header in JSON format: {"api_key": "YOUR_API_KEY"}.
  5. Write your query in the query editor and execute by clicking the arrow button (see below for query example).

You can test your access by querying yourself:

query {
  profile {
    email
    firstName
    lastName
    phoneNumber
  }
}

If everything worked correctly, this will display your details. You're all set to start making queries.

Accessing the sidebar docs

All types in a GraphQL schema include a description field compiled into documentation. The collapsible Docs pane on the left side of the Explorer page allows you to browse documentation about the type system. The docs are automatically updated and will drop deprecated fields.

The Docs sidebar contains the same content that is automatically generated from the schema in the Reference docs though it is formatted differently in places.

Using the variable pane

Some example calls include variables written like this:

query($first: Int, $orderBy: [String]) {
  stockRatings(first: $first, orderBy: $orderBy
  ) {
    edges {
      node {
        date
        growthRating
        macroRating
        riskRating
        returnRating
        technicalRating
        totalRating
        valuationRating
        stock {
          id
          name
        }
      }
    }
  }
}
variables {
  "first": 10,
  "orderBy": ["-total_rating"]
}

This is the correct format to submit the call using a POST request in a curl command (as long as you escape newlines).

If you want to run the call in the Explorer, enter the query segment in the main pane and the variables in the Query Variables pane below it. Omit the word variables from the Explorer:

{
  "first": 10,
  "orderBy": ["-total_rating"]
}

Troubleshooting errors

Because GraphQL is introspective, the Explorer supports:

  • Intelligent typeaheads aware of the current schema
  • Validation error previews as you type

If you enter a query that is not well-formed or does not pass schema validation, a popup warns you of an error. If you run the query, the error returns in the response pane.

A GraphQL response contains several keys: a data hash and an errors array.

{
  "data": null,
  "errors": [
    {
      "message": "Objects must have selections (field 'nodes' returns StockRating but has no selections)",
      "locations": [
        {
          "line": 5,
          "column": 8
        }
      ]
    }
  ]
}