Skip to content

GraphQL API Overview

The Aster Policy Engine exposes a GraphQL API for querying and managing policies. It is built on SmallRye GraphQL (the MicroProfile GraphQL implementation) and offers the full suite of MicroProfile GraphQL features including built-in introspection, type safety, and a hosted schema endpoint.

Endpoint

PurposeURL
Query / Mutation executionPOST /graphql
Schema (SDL)GET /graphql/schema.graphql

Headers

HeaderValueRequired
AuthorizationBearer <token>Yes
Content-Typeapplication/jsonYes
X-Tenant-IdTenant identifier stringYes
Idempotency-KeyClient-generated unique string (UUID recommended)Mutations only

Idempotency-Key

Providing an Idempotency-Key on mutation requests ensures that retrying a failed or timed-out request does not apply the operation a second time. The server caches the mutation result keyed on this value for 24 hours. This header is optional but strongly recommended for write operations.

Request Format

All requests must be HTTP POST with a JSON body conforming to the GraphQL over HTTP specification:

json
{
  "query": "query { ... }",
  "variables": {},
  "operationName": "OptionalOperationName"
}
FieldTypeRequiredDescription
querystringYesGraphQL document containing the operation to execute.
variablesobjectNoNamed variable values referenced in the query.
operationNamestringNoDisambiguates which operation to run when query contains multiple named operations.

Response Format

json
{
  "data": {},
  "errors": []
}

A 200 OK HTTP status is returned for all well-formed GraphQL responses, including partial successes. Always inspect the errors array — a non-empty value indicates that one or more field resolvers encountered an error, even when data is partially populated.

Schema

Download the full schema in SDL format:

bash
curl -X GET https://policy.aster-lang.dev/graphql/schema.graphql \
  -H "Authorization: Bearer <token>"

Error Handling

GraphQL errors follow the GraphQL specification error format:

json
{
  "data": null,
  "errors": [
    {
      "message": "Policy not found",
      "locations": [{ "line": 2, "column": 3 }],
      "path": ["getPolicy"],
      "extensions": {
        "code": "NOT_FOUND",
        "classification": "DataFetchingException"
      }
    }
  ]
}
Extension FieldDescription
codeMachine-readable error code (e.g. NOT_FOUND, FORBIDDEN, VALIDATION_ERROR).
classificationSmallRye GraphQL error classification.

HTTP Status Codes

StatusMeaning
200 OKGraphQL response returned (check errors for partial failures).
400 Bad RequestRequest body is not valid JSON or the GraphQL document is syntactically invalid.
401 UnauthorizedMissing or invalid bearer token.
403 ForbiddenToken is valid but the caller lacks the required role for the requested operation.
500 Internal Server ErrorUnexpected engine failure before the GraphQL layer could respond.

Released under the MIT License.