[]
        
(Showing Draft Content)

Using GraphQL

Wyn Enterprise uses GraphQL to send a query to your API and obtain the required data. On this page, you will find the instructions to access GraphiQL from Admin Portal and manage various resources including,

Access GraphiQL from Admin Portal

  1. To access GraphiQL, navigate to the Admin Portal and click the graphiql link on the Dashboard under the Links section.

    Access GraphiQL from Admin Portal

  2. GraphiQL IDE will open in a new tab. Use the input box on the left side to enter a query and click the execute button on the top right corner your screen to get an output on the right side. You can also change the settings of the query using the Prettify, Merge, and Copy buttons on the toolbar next to the execute button. Use the History button to view the history of queries used in GraphiQL. To access the GraphiQL API documentation, click the Docs link on the top right corner of your screen.

    GraphiQL IDE interface

  3. In the Documentation Explorer, you can view the query and mutation documentation.

    GraphiQL - Documentation Explorer

  4. On clicking the PortalQuery option, you get the list of the queries used to fetch data.

    GraphiQL Documentation Explorer - Portal Query

  5. On clicking the Mutation option, you get the list of queries used to modify data on the server side.

GraphiQL Documentation Explorer - Mutation

Get the list of resources

You may want to obtain a list of all the resources available to you. The following query returns the list of all resources along with the ID and file name of all the resources.

query
  {
     documents {
       id
       filename
     }
  }

Get details of all resources

Along with the resource ID and file name, you can also obtain other details such as title, file type, and extension, created date, created by, modified date, modified by information; and operations allowed on the resource, using additional attributes available in the API. The following table elaborates the attributes available in documents object in the previous query:

Attributes

Description

id

Gets the resource ID or document ID

filename

Gets the name of the file (eg. Auto Insurance.dbd)

title

Gets the name of the document (eg. Auto Insurance)

type

Gets the type of the document (eg. dbd)

ext

Gets the extension of the document (eg. .dbd)

created

Gets the date and time when the document was created (eg. 2020-01-22T10:54:33.451178Z)

created_by{}

Obtains information on user who created the document. Some of the attributes available are:

  • name - of the user

  • email - of the user

  • id - of the user

  • roles - assigned to the user

  • home - home document id

modified

Gets the date and time when the document was modified

modified_by{}

Obtains information on user who modified the document. The attributes available are same as listed in created_by{}

effective_ops

Lists the operations allowed on document (eg. Create, Read)

security{}

Obtains information on owner and access control for document. The following attributes are available:

  • ownerid - user id of the owner

  • permissions{} - list of roles with allowed operations. It takes following values:    sub{} - permissions on user, role, or group     ops - operations allowed

Get details of a specific resource

If you want to obtain details of a specific resource, replace the "key" in the following query with the one specified in the following table.

{
  query: documenttypes(key: "key") {
      documents {
        id
        filename      
    }
  }
}

Resource Type

Key

Report

rdl

Dashboard

dbd

Dataset

dataset

Data Source

dsc

Image

image/jpeg, image/bmp,

image/gif, image/png

Theme

theme

Update a resource

Update Permissions

To update permissions, obtain the ID of the resource and put it in the following mutation.

mutation 
  {
    updatePermissions( documentId: "documentID" , 
      grant: [ { role:"TestRole",
      ops: [ Read, Update ]}] , 
      revoke: [ { role:"Everyone", ops: [ Read ]}] )
  }

Update the Category of a resource

You need to have the category ID of the resource you want to modify. See Using GraphQL to Manage Categories topic on how to obtain a category ID.


Assign a Category to a resource


Obtain the ID of the resource and the tag ID (or category ID) and put it in the following mutation to add a tag to the resource.

mutation
  { 
    tagDocument(
    tagId: "tagid",
    documentId: "documentID")
  } 

Delete Category from a resource


Obtain the ID of the resource and the tag ID (or category ID) and put it in the following mutation to delete the tag from the resource.

mutation
  {
    untagDocument(
     tagId: "tagid",
     documentId: "documentID") 
  }

Delete a resource

You need to first obtain the ID of the resource and put it in the following mutation to delete the resource.

mutation
  {    
    deleteDocument(documentId: "documentID") 
    {
      deleted_id
    }
  }