Skip to main content
Amplication can be integrated with any Internal Developer Platform (IDP).

Prerequisites

  • A workspace in Amplication
  • An API token for the workspace

Amplication + GraphQL

Amplication is built with GraphQL in mind. This means that you can easily integrate Amplication with any IDP using by calling the GraphQL API.

Authentication

Your calls to the Amplication GraphQL API will need to be authenticated. You should use the API token to authenticate your calls. This is done by sending the token in the Authorization header of your request:
{
    Authorization: "Bearer YOUR_API_TOKEN"
    Content-Type: "application/json"
}

Requests

Since we’re working with GraphQL, you’ll need to make requests to the GraphQL endpoint. The endpoint is https://server.amplication.com/graphql and it will accept POST requests for queries and mutations. This is a sample query:
const query = `
  query searchCatalog($where: ResourceWhereInputWithPropertiesFilter) {
    catalog(where: $where) {
      totalCount
      data {
        id
        name
      }
    }
  }
`;

const variables = {
  take: 100,
  skip: 0,
  where: {
    resourceType: { in: ["ServiceTemplate"] }
  }
};

fetch('https://server.amplication.com/graphql', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    query,
    variables
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Get Requests

  • Templates
  • Resources
  • Alerts
This is how you fetch templates.
query searchCatalog($where: ResourceWhereInputWithPropertiesFilter, $take: Int, $skip: Int) {
    catalog(where: $where, take: $take, skip: $skip) {
        totalCount
        data {
            id
            name
            description
            resourceType
            project {
                id
                name
            }
            blueprint {
                id
                name
            }
        }
        __typename
    }
}
{
    "take": 100,
    "skip": 0,
    "where": {"resourceType": {"in": ["ServiceTemplate"]}},
}
{
    data: {
        catalog: {
            data: {
                {
                    "id": "cm6zln01a0209utjtlorazri1",
                    "name": "Node.js Template",
                    "description": "Template created from an existing resource",
                    "resourceType": "ServiceTemplate",
                    "project": {
                        "id": "cm6zlfk2o01liutjtdw8xj7f0",
                        "name": "Base Project"
                    },
                    "blueprint": {
                        "id": "cm6gb3j00000p14gz2n11otq4",
                        "name": "Node.js Service (Amplication's Standard)"
                    }
                },
                {
                    "id": "u1z6ijno0lrzmlra1ta9c200t",
                    "name": ".Net Template",
                    ...
                }
            }
        }
    }
}

Post Requests

  • Scaffold Resource
  • Code Re-build
Scaffolding a resource from an existing template is something we can do often.
mutation createServiceFromTemplate($data: ResourceFromTemplateCreateInput!) {
  createResourceFromTemplate(data: $data) {
    id
    name
    description
    __typename
  }
}
{
  "data": {
    "name": "Resource Name",
    "description": "Resource Description",
    "project": {
      "connect": {
        "id": "cm6zlfk2o01liutjtdw8xj7f0"
      }
    },
    "serviceTemplate": {
      "id": "cm6zln01a0209utjtlorazri1"
    }
  }
}
{
  "data": {
    "createResourceFromTemplate": {
      "id": "cm7hf6bd20000r00ucwlkads3",
      "name": "Resource Name",
      "description": "Resource Description",
      "__typename": "Resource"
    }
  }
}
I