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

This is how you fetch templates.

Post Requests

Scaffolding a resource from an existing template is something we can do often.