x
Wyn 4.0 launches with more extensibility, enhanced embedded business intelligence, and an improved end-user experience. Learn More Wyn 4.0 launches, enhanced embedded business intelligence, improved end-user experience. Learn More Wyn 4.0 launches

Wyn Enterprise: Using GraphQL to Manage Reports

This page discusses using Wyn RESTful API through GraphQL query language to work with reports.

Get information on a report

To obtain information on report properties and parameters the list of all the resources available to you, use reportInfo as follows.

Request Example

query {
  reportInfo(reportId: "010a48f3-7e6c-485e-97bb-5df5dbd9fb8e") {
    name, displayType, sizeType, isFPL,
    parameters {
      name, prompt, dataType, selectAllValue,
      allowBlank, nullable, multiValue, multiline,
      hidden, usedInQuery, dependsOn, dateOnly,
      validValues {
        values { label, value }
      },
      defaultValue { values }
    }
  }
}

Response Example

"data": {
    "reportInfo": {
      "name": "param test",
      "displayType": "Page",
      "sizeType": "Default",
      "isFPL": false,
      "parameters": [
        {
          "name": "Parameter1",
          ...
          "validValues": {
            "values": [
              {
                "label": "Param1 label 1",
                "value": "param1value1"
              },
              {
                "label": "Param1 label 2",
                "value": "param1value2"
              },
              {
                "label": "Param1 label 3",
                "value": "param1value3"
              }
            ]
          },
          "defaultValue": {
            "values": [
              "param1value2"
            ]
          }
        }
    ...

The following table elaborates key attributes available in reportInfo object.

Attributes Description
id Gets the resource ID or document ID
name name of the report
displayType eg. Page
sizeType eg. Default, FitToPage
isFPL Returns boolen value, whether the report is a fixed page layout
parameters{} Information on report parameters. The following attributes are available:
  • name - of the parameter
  • prompt - prompt of the parameter
  • dataType - data type of the parameter
  • selectAllValue - value passed in Select All Value property in case of multivalue parameter
  • allowBlank - if allow blank is set
  • nullable - if null value is allowed in parameter
  • multiValue - if the parameter is multivalue
  • multiline - if multi line text is allowed
  • hidden - if the parameter is hidden
  • usedInQuery - if the parameter is used in query
  • dependsOn - if parameter depends on another parameter in case of cascading parameters
  • validValues {} - values valid values of the parameter

Get information on report parameters

To obtain available values for child parameter depending on selected parent parameter values, use reportParameterValues in query as follows.

Request Example

query {
  reportParameterValues(
    reportId: "5d6fa0cb92c4090094da243d",
    parameterRequest: {
      request: ["Parameter4"],
      values: [{
        key: "City",
        values: ["London"]
      }]
    }
  ) {
        parameters {
      key,
      value { validValues { label, value }, values } }
  }
}

Response Example

{
  "data": {
    "reportParameterValues": {
      "parameters": [
        {
          "key": "Parameter4",
          "value": {
            "validValues": [
              {
                "label": "Around the Horn",
                "value": "Around the Horn"
              },
              {
                "label": "B's Beverages",
                "value": "B's Beverages"
              }
            ],
            "values": [
              "Around the Horn"
            ]
          }
        }
      ]
    }
  },
  "errors": null
}

Export a report

To export a report using provided export settings and report parameters, use exportReport in mutation. If there are errors during export result streaming, check export errors after reading result stream, use resultUrl and verificationUrl.

Request Example

mutation {
   exportReport(
     reportId: "c788aca9-d72e-4b2d-ab55-167e380b670f",
     exportExtension: "pdf",
     renderPayload: {
     settings: [{
     key: "IsPaginated",
     value: "false"
     }]
    })
  {
   resultUrl,
   verificationUrl
 }
}

Response Example

{
  "data": {
    "exportReport": {
      "resultUrl": "/api/workerJob/b9a39275-fc5a-43cd-9bfc-dd94622f1228",
      "verificationUrl": "/api/workerJob/b9a39275-fc5a-43cd-9bfc-dd94622f1228/verify"
    }
  },
  "errors": null
}

The following table elaborates key attributes available in exportReport object.

Attributes Description
reportId Report ID of the report you want to export
exportExtension The rendering extension or export type. Acceptable values are: "pdf", "csv", "excel", "docx", "html", "image", and "json".
renderPayload{} The information on report parameters.

Render a report

To render or view a report, use the render mutation. The mutation returns job id when the report is rendered, which should be used to obtain document Id or error message. See obtaining Job status in the next section.

Request Example

mutation {
  render(
    reportId: "5d6fa0cb92c4090094da243d",
    renderPayload: {
      parameters: [{
        key: "Parameter1", value: "param1value2"
      }, {
        key: "Parameter2", value: "param2value1"
      }, {
        key: "City", value: "London"
      }, {
        key: "Parameter4", value: "Around the Horn"
      }]
    }
  ) {
    jobId
  }
}

Response Example

{
  "data": {
    "render": {
      "jobId": "799529e3-0c59-48bc-a97c-8b82cd719efc"
    }
  },
  "errors": null
}

Job status

To obtain rendering job status - RUNNING, SUCCESS, or ERROR. If a job has completed successfully, documentId field is set to rendered document id, which can be used further for export using exportDocument mutation.

If the job fails, error field contains error message. Note that if a job is running, server will wait for the job to finish for a period of time before answering the client, so there may be delay on server-side.

Request Example

query {
  job(
    jobId: "799529e3-0c59-48bc-a97c-8b82cd719efc"
  ) {
    status, documentId, error
  }
}

Response Example

{
  "data": {
    "job": {
      "status": "SUCCESS",
      "documentId": "77260328-9ae0-4f41-ad4f-cfb457ab04b7",
      "error": null
    }
  },
  "errors": null
}

Export a document

To export a rendered document using provided export settings use exportDocument mutation.

Note that the report parameters are closely connected to the rendered document and cannot be changed without calling /render mutation as explained in Render report section.

Returns export result URL and result verification URL

Request Example

mutation {
  exportDocument(
    documentId: "77260328-9ae0-4f41-ad4f-cfb457ab04b7",
    exportExtension: "pdf",
    renderPayload: {}
  ) {
    resultUrl, verificationUrl
  }
}

Response Example

{
  "data": {
    "exportDocument": {
      "resultUrl": "/api/workerJob/a4480e07-9a84-4aa6-adc2-08c498abb86c",
      "verificationUrl": "/api/workerJob/a4480e07-9a84-4aa6-adc2-08c498abb86c/verify"
    }
  },
  "errors": null
}

Close Document

To remove rendered document from server, use the following mutation.

Request Example

mutation {
  closeDocument(
    documentId: "26f7f1ad-0536-4a8c-8884-bd43d923b308")
}

Response Example

{
  "data": {
    "closeDocument": true
  },
  "errors": null
}
mutation {
  closeDocument(
    documentId: "26f7f1ad-0536-4a8c-8884-bd43d923b308")
}

Response Example

{
  "data": {
    "closeDocument": true
  },
  "errors": null
}