GraphQL API

In this section we will be providing examples that you can use inside your very own playground available here http://localhost:3000/graphqlopen in new window (if you activated it).

Whisps: Query

whispById

Retrieves the matching whisp by its _id.

query getWhispById($whispId: String!) {
  whispById(
    id: $whispId
  ) {
    _id # fields you want to retrieve from the whisp
  }
}

Query variables

{ "whispId": "5ed644d46f91b10034d731f1" }

You can find the list of available fields here.

whisps

Retrieves all the whisps matching a set of conditions.

query getWhisps($filter: JSONObject!, $sort: JSONObject, $limit: Int) {
  whisps(filter: $filter, sort: $sort, limit: $limit) {
    _id # fields you want to retrieve from the whisp
  }
}

You can find the list of available fields here.

Query variables

{
  "filter": { "att1": "value1" },
  "sort": { "att1": 1  },
  "limit": 3
}
  • The filtering options are described here.
  • The /whisps query accepts mongoose filtering functionality.
  • The sort variable accepts two values 1 (ascending), and -1 (descending)
  • You can sort on nested fields this way:
{
  "sort": { "att1.att2": 1  }
}

countWhisps

Returns an array with count of matching whisps, grouped by the specified object.

This query uses MongoDB aggregation to group and count objects. It is the same as the MongoDB countDocuments() functionopen in new window but allows a custom group object.

Parameters

  • filter: optional JSONObject! array of filters to apply. These will be applied with OR logic, all whisps matching any of the filters will be counted. Filtering options accept mongoose filtering functionality, described here.
  • group: optional JSONObject! which contains the object fields that you would like to group on.
query getWhispCountGrouped($filters: [JSONObject!], $group: JSONObject! ) {
  countWhisps(filter: $filters, group: $group)
  {
    _id
    count
  }
}

The query variables below provide two filters which will be applied with an OR condition, and two grouping fields which will be used to group counts based on object properties. The name and number of grouping fields is arbitrary.

Notes

  • Both filter and group parameters are optional.
  • If no group is specified your query will return a single group with a null _id object.
  • If there are zero matches for the filter options, then the result of the query will be an empty array [].

TIP

For performance reasons it is strongly recommended to reduce the number of filters in the filter array. Instead, if possible try to provide only a few high level filters to reduce the scope of the data returned, and then rely on more granular grouping to get the specific count you need.

  {
    "filters":[{
      "applicationID": "SMUDGE",
      "data.customData.id": "503"
    },
    {
      "applicationID": "SMUDGE",
      "data.customData.id": "504"
    }],
    "group": { "mainGrouping": "$data.customData.id", "secondaryGrouping": "$data.customData.description"}
  }

Example output from the query above:


"countWhisps": [
    {
      "_id": {
        "mainGrouping": "503",
        "secondaryGrouping": "AAAA"
      },
      "count": 100
    },
    {
      "_id": {
        "mainGrouping": "504",
        "secondaryGrouping": "AAAA"
      },
      "count": 297
    },
    {
      "_id": {
        "mainGrouping": "504",
        "secondaryGrouping": "BBBB"
      },
      "count": 3
    }

Example output with no group parameter (in this case to simplify the object you also just exclude _id from the query to return the count field only):

"countWhisps": [
  {
    "_id": null,
    "count": 505797
  }

Whisps: Mutation

createWhisp

Creates a new whisp.

mutation createWhisp($whisp: WhispInputType!) {
  createWhisp(whisp: $whisp) {
    _id # fields you want to retrieve from the created whisp
  }
}

Query variables

{
    "whisp": {
        "closed": false // fields you want to populate
    }
}

You can find the list of available fields here.

updateWhisp

Updates an existing whisp.

mutation updateWhisp($whisp: WhispInputType!, $id: String) {
  updateWhisp(whisp: $whisp, id: $id) {
    _id # fields you want to retrieve from the updated whisp
  }
}

Query variables

{
    "whisp": {
        "closed": false // fields you want to update
    },
    "id": "5ed644d46f91b10034d731f1"
}

You can find the list of available fields here.

replaceWhisp

Replaces an existing whisp. This endpoint has the same signature as updateWhisp, however instead of updating the fields provided in the whisp parameter, it will instead replace the whisp in the database with the whisp parameter.

mutation replaceWhisp($whisp: WhispInputType!, $id: String) {
  replaceWhisp(whisp: $whisp, id: $id) {
    _id # fields you want to retrieve from the updated whisp
  }
}

Query variables

{
    "whisp": {
        "closed": false // fields you want to populate
    },
    "id": "5ed644d46f91b10034d731f1"
}

You can find the list of available fields here.

deleteWhisp

Deletes the matching whisp by its _id.

mutation deleteWhispById($whispId: String!) {
  deleteWhisp(
    id: $whispId
  )
}

Query variables

{ "whispId": "5ed644d46f91b10034d731f1" }

Whisps: Subscription

whispAdded

Subscribes the caller to the 'whispAdded' event. The caller will receive the new whisps that match the provided filter.

subscription whispSubscription($filter: JSONObject!) {
  whispAdded(filter: $filter) {
    _id # fields you want to retrieve from the created whisp
  }
}

Query variables

{
  "filter": { "att1": "value1" }
}
  • The filtering options are described here.

In this section we will be providing examples that you can use inside your very own playground available here http://localhost:3000/graphqlopen in new window (if you activated it).

TagGroups: Query

tagGroupById

Retrieves the matching tagGroup by its _id.

query getTagGroupById($tagGroupId: String!) {
  tagGroupById(
    id: $tagGroupId
  ) {
    _id # fields you want to retrieve from the tagGroup
  }
}

Query variables

{ "tagGroupId": "5ed644d46f91b10034d731f1" }

You can find the list of available fields here.

tagGroups

Retrieves all the tagGroups matching a set of conditions.

query getTagGroups($tagGroup: TagGroupInputType!) {
  tagGroups(tagGroup: $tagGroup) {
    _id # fields you want to retrieve from the tagGroup
  }
}

Query variables

{
    "tagGroup": {
        "title": "I'm looking for this specific title" // fields you want to filter on
    }
}

If you want to retrieve all the tagGroups you can set the tagGroup parameter to {}

You can find the list of available fields here.

TagGroups: Mutation

createTagGroup

Creates a new tagGroup.

mutation createTagGroup($tagGroup: TagGroupInputType!) {
  createTagGroup(tagGroup: $tagGroup) {
    _id # fields you want to retrieve from the created tagGroup
  }
}

Query variables

{
    "tagGroup": {
        "title": "A great title for a new tagGroup" // fields you want to populate
    }
}

You can find the list of available fields here.

updateTagGroup

Updates an existing tagGroup.

mutation updateTagGroup($tagGroup: TagGroupInputType!, $id: String) {
  updateTagGroup(tagGroup: $tagGroup, id: $id) {
    _id # fields you want to retrieve from the updated tagGroup
  }
}

Query variables

{
    "tagGroup": {
        "title": "This title is definetly better" // fields you want to update
    },
    "id": "5ed644d46f91b10034d731f1"
}

You can find the list of available fields here.

replaceTagGroup

Replaces an existing tagGroup. This endpoint has the same signature as updateTagGroup, however instead of updating the fields provided in the tagGroup parameter, it will instead replace the tagGroup in the database with the tagGroup parameter.

mutation replaceTagGroup($tagGroup: TagGroupInputType!, $id: String) {
  replaceTagGroup(tagGroup: $tagGroup, id: $id) {
    _id # fields you want to retrieve from the updated tagGroup
  }
}

Query variables

{
    "tagGroup": {
        "title": "A really cool title" // fields you want to populate
    },
    "id": "5ed644d46f91b10034d731f1"
}

You can find the list of available fields here.

deleteTagGroup

Deletes the matching tagGroup by its _id.

mutation deleteTagGroupById($tagGroupId: String!) {
  deleteTagGroup(
    id: $tagGroupId
  )
}

Query variables

{ "tagGroupId": "5ed644d46f91b10034d731f1" }

Webhooks: Query

You can find the list of available fields here.

webhooks

Retrieves all the webhooks.

query getWebhooks {
  webhooks {
    _id # fields you want to retrieve from the webhook
  }
}

Webhooks: Mutation

createWebhook

Creates a new webhook.

mutation createWebhook($webhook: WebhookInputType!) {
  createWebhook(webhook: $webhook) {
    _id # fields you want to retrieve from the created webhook
  }
}

Query variables

{
    "webhook": {
        "url": "https://webhook.url",
        "events": ["EVENT_NAME"],
        "filter":  { "applicationId": "application1"}
    }
}

deleteWebhook

Deletes the matching webhook by its _id.

mutation deleteWebhook($webhookId: String!) {
  deleteWebhook (
    id: $webhookId
  )
}

Query variables

{ "webhookId": "5ef5f304a07efa0041904d52" }
Last Updated:
Contributors: semantic-release-bot