An introduction to operations

Basics

Operations are the interface where developers can interact with the Mulah system. Retrieving and manipulating data can be done using http post request. The header of the request must contain a Mulah admin assigned token as well as a form body with an operation name and its required arguments.

Endpoint

All requests should be made to the url below.

https://mulahpoints.com/third_party

Generic Request

Below is an example of using the api via curl.

Text beginning with $ are values to be replaced.

curl \
-X POST \
-H "Content-Type: application/json" \
-H "Token: $TOKEN" \
-d '{"operation_name": $OPERATION_NAME}' \
https://mulahpoints.com/third_party

Types of Operations

Operations can be divided into two distict types.

Index of operations can be found here.

  • Queries
    • Read operation used to retrieve data
    • No side-effect
  • Mutations
    • Write operation used to manipulate existing data
    • Causes side-effect

Errors

Mutation operations contains an inner errors field.

This is to alert users when a failure to perform intended side effect occurs.

Query Response

Below is a structural example of a response from a query operation

{
    "data": {
        $RESOURCE_NODE: {
            $MULTIPLE_RESOURCE: [
                {
                    $FIELD
                    $NESTED_RESOURCE {
                      $NESTED_FIELD
                    }
                }
            ],
            $SINGLE_RESOURCE {
                $FIELD
            }
        }
    },
    "errors": [
      {
        "message": $RUNTIME_ERROR
      }
    ]
}

Mutation Response

While a structural example of a mutation operation would like below

{
    "data": {
        $RESOURCE_NODE: {
            $MULTIPLE_RESOURCE: [
                {
                    $FIELD
                    $NESTED_RESOURCE {
                      $NESTED_FIELD
                    }
                }
            ],
            $SINGLE_RESOURCE {
                $FIELD
            },
            "errors": [
                {
                  "message": $OPERATION_ERROR
                }
            ]
        }
    },
    "errors": [
      {
        "message": $RUNTIME_ERROR
      }
    ]
}