Query the GraphQL schema

Querying the Skedulo GraphQL schema.

You can query Skedulo’s GraphQL schema to return specific information that you require.

The GraphiQL web extension in the Skedulo web application supports documentation for the schema, and provides prompts for supported fields on objects to make it easier to construct valid queries.

This section covers some basic queries to get you started. To test queries yourself or to explore the GraphQL schema, open the GraphiQL web extension in the web application or see the Skedulo GraphQL Schema Documentation.

Use GraphQL to retrieve job information

After you have created a job in Skedulo, you can retrieve all of the information about that specific job using a GraphQL query.

To do this, run a query on the job UID.

Using Skedulo Lens, you would pass this query to the https://api.skedulo.com/graphql/graphql endpoint with the appropriate access token credentials (see Authentication).

{
  jobsById(UID: "a0E6F00001np3tSUAQ") {
    UID,
    Name,
    Start,
    Duration,
    JobStatus,
    JobAllocations {
      Resource {
        Name
      }
      Status
    }
  }
}

The query should return the data about the job in JSON format, as shown in the following example:

{
  "data": {
    "jobsById": {
      "UID": "a0E6F00001np3tSUAQ",
      "Name": "JOB-0039",
      "Start": "2018-03-12T04:10:00.000Z",
      "Duration": 120,
      "JobStatus": "Pending Dispatch",
      "JobAllocations": [
        {
          "Resource": {
            "Name": "Alfred E. Neuman"
          },
          "Status": "Pending Dispatch"
        },
        {
          "Resource": {
            "Name": "Rube Goldberg"
          },
          "Status": "Pending Dispatch"
        },
        {
          "Resource": {
            "Name": "Isaac Newton"
          },
          "Status": "Pending Dispatch"
        }
      ]
    }
  }
}

Note that GraphQL allows you to navigate the object graph, returning only the parts of each object you request.

These examples are only scratching the surface of what can be done with GraphQL. We recommend following the GraphQL tutorial and exploring the API with your examples.

Retrieve a list of all jobs

You can use the following GraphQL query to retrieve a list of all jobs:

query {
  jobs {
    edges {
      node {
        UID
        Name
        Description
        JobStatus
      }
    }
  }
}

This returns a list of all jobs created in your Skedulo workspace, regardless of the job status.

{
  "data": {
    "jobs": {
      "edges": [
        {
          "node": {
            "UID": "0014a76c-dfa1-4e78-87b3-635b7d7f4897",
            "Name": "JOB-0007",
            "Description": "",
            "JobStatus": "Cancelled"
          }
        },
        {
          "node": {
            "UID": "0014586b-3fa3-4f74-a5b1-a47f22a4b3a2",
            "Name": "JOB-0009",
            "Description": "new job using graphql",
            "JobStatus": "Pending Dispatch"
          }
        },
        {
          "node": {
            "UID": "00146e2f-c8db-4593-adc2-084abc866785",
            "Name": "JOB-0006",
            "Description": "new job using GraphQL",
            "JobStatus": "Pending Allocation"
          }
        },
        ...
      ]
    }
  }
}

Skedulo GraphQL limits the number of results returned to 200 records per query. Therefore, you might want to use pagination support if your jobs query returns a high number of results.

You can also use EQL filters to return jobs that match specific criteria such as JobStatus, Location, or Urgency. Use an introspection query to list all object fields that you can use to filter your query results.

Introspection queries

GraphiQL uses introspection to populate its docs and in most cases, you will not need to manually write introspection queries. The introspection system asks GraphQL what types are available for you to query. Run a query using the __schema field, which is available on the root type of a query:

{
  __schema {
    types {
      name
    }
  }
}

This query returns a list of all types that can be queried using the Skedulo GraphQL API.

You can use an introspection query on a type to find out more information about it. Run the following GraphQL query to find out more about Jobs:

{
  "data": {
    "__type": {
      "name": "Jobs",
      "kind": "OBJECT"
    }
  }
}

You can also use a __type query to fetch all of the fields for Jobs. This query returns all of the fields that are defined on the Jobs object:

{
 __type(name: "Jobs") {
   name
   fields {
     name
     type {
       name
       kind
     }
   }
 }
}

EQL filters

Most of the GraphQL queries take a filter parameter, which is an Elastic Query Language (EQL) filter string. EQL is a simple Domain Specific Language (DSL) that filters results.

It is similar to an SQL WHERE clause.

Example: Query to fetch all queued jobs

query {
  jobs(filter: "JobStatus == 'Queued'") {
    edges {
      node {
        UID
        Name
        Description
        JobStatus
      }
    }
  }
}

An EQL filter is a boolean expression that can refer to the fields of the object being queried.

Operators

Operators Description
==, != Equal To, Not Equal To
<, <=, >, >= Comparison Operators
LIKE Wildcard match (case insensitive, use % as a wildcard).
NOTLIKE Wildcard match (case insensitive, use % as a wildcard).
IN Determines if a value is in a list.
NOTIN Determines if a value is not in a list.
INCLUDES Determines whether a picklist includes a given value.
EXCLUDES Determines whether a picklist excludes a given value.
AND, OR Boolean expressions
(SELECT <Field> FROM <Object> WHERE <Filter>) Apply a filter sub-query to a selected field.

Literals

Type Examples
String "A String", 'A single quoted string'
Null null
Boolean true, false
Integer 997
Floating Point 25.96
Instant 2018-06-04T09:35:76.000Z (note milliseconds are required)
Local Time 09:35:05
Local Date 2018-06-04
Duration 15 minutes, 1 hour

Some example filters:

  • Name == 'Skedulo'
  • (Name == "Skedulo" OR Description LIKE '%desc%') AND (Locked == true)
  • Start == null
  • Start > 2018-06-01T00:00:00.000Z
  • Name IN ['Salesforce', 'Standalone']
  • UserTypes INCLUDES "Admin"
  • Contact.Account.Name LIKE 'Jane%'
  • UID IN (SELECT JobId FROM JobOffers WHERE Status != 'Closed')
  • FirstName NOTIN ['Test', 'delete']
  • UID NOTIN (SELECT UserId FROM Resources)
  • UserTypes EXCLUDES 'Administrator'