Select Page

Excerpt:
Explore the possibilities of GraphQL for edoras one using a GraphQL server atop the existing edoras REST API

(note: No edoras backend developers were harmed during development of this service)

graphql-atop-edoras-rest

More Details:

graphql-atop-edoras-rest-2


 

Web/mobile Apps or arbitrary clients use GraphQL to fetch data from edoras one

GraphiQL: in-browser IDE for exploring your data using GraphQL

GraphQL Server
– provides the edoras GraphQL API i.e. the edoras Type Definitions
– maps GraphQL queries/mutations to edoras REST calls

We defined two queries – search and workItem:

type Query {

    # find work items
    search(

      # filter work items by type (multiple types possible)
      type: [WorkItemType],

      # limit the search result (can be used for pagination)
      limit: Int = 10,

      # show results starting with this offset (can be used for pagination)
      offset: Int = 0,

      # sort the result by sort term, ascending or descending
      # documentation: https://documentation.edorasware.com/latest#sort-terms
      sort: [SortEnum],

      # find work items as descendants of a given work item id
      descendantsOf: String,

      # filter work items by their state (multiple states possible)
      state: [StateEnum],

      # filter work items by dashboard (i.e role): user, modeler or admin
      dashboard: Dashboard

    ): [WorkItemInterface]

    # ------------------------------------------

    #find a specific work item by id or key (Either id or key must be given)
    workItem(

      # Unique id. Either id or key must be given
      id: String,

      # Unique key. Either id or key must be given
      key: String,

    ): WorkItemInterface
}

 

If we add further Type Definitions we would get a concise schema for edoras and could run queries like so:

Example 1:
get all work items of type APP_MODEL in state OPEN sorted by descending modification date + limit the result to 30 entries:

graphiql-search-1

This is a screenshot of the open source, interactive, in-browser IDE called GraphiQL.
In short, here is how this works:
If you change the query on the left side and press the above play-button you get the result on the right side.

You immediately understand:

  • The structure of the query determines the structure of the result
  • The result is exactly what you requested for, not more or less

Now let’s dig a little bit deeper:

Assume you want to show all models of a specific APP_MODEL and some other information down the data hierarchy, you start typing…

graphiql-search-2

add ‘descendantsOf’ and id. Add the fields to display…

graphiql-search-3

and run the query…

Example 2: get all Work Items of an App Model:

graphiql-search-4

nested data: owner with title, id, etc…

graphiql-search-5

and query result:

graphiql-search-6

Depending on the returned work item type…

graphiql-search-7

…here: …on CaseModel… I want to return the initForm with key and name:

graphiql-search-8

And now drill down on the fields for each form….

fields returns an array of FormComponentInterface…

graphiql-search-9

show field description, type (xmlTag) and label…

graphiql-search-10

the form fields can be of different type…

graphiql-search-11

…what are the subforms of a MultiSubFormComponent:

graphiql-search-12

(you recognize that each subform in the MultiSubFormComponent is itself a FormModel)

You probably realize the potential here…

  • we fetch data over several levels in the data hierarchy and its still very comprehensive
  • and because of the Type System in the editor you get:
    • Syntax highlighting
    • Real-time error highlighting and reporting
    • intelligent type ahead of fields, arguments, types, and more

What do we cover with the edoras GraphQL API:

  • fetch work items
  • change / add work items (mutations)
  • basically we can cover everything in the vis modeler,
    i.e. everything what is exposed via the REST API

What can you do with the edoras GraphQL API:

  • get the freedom to build arbitrary web and mobile applications atop edoras server

Coming next:

edoras GUIs build with edoras GraphQL – stay tuned…