Skip to content

Martini Creating GraphQL API Schemas

A GraphQL server acts as a bridge between your clients and your backend services, handling client requests by fetching the required data. With Martini, the creation of a GraphQL server is streamlined, allowing your GraphQL schemas to be consumed with ease. This server dynamically interacts with your services when executing queries or mutations.

To facilitate the creation of a GraphQL server, Martini provides a Create API wizard. This tool simplifies the setup process, guiding you through the necessary steps to get your GraphQL API up and running.

Step-by-Step Guide

1. Launching the Create API Wizard

Start by opening the Martini Navigator. Right-click on the directory where you intend to house your API, and select New > Create API wizard from the context menu. This action initiates the wizard.

2. Configuring API Details

Within the wizard, select Publish as the action type and proceed to the next step. Here, you will be prompted to provide a name for your API. Ensure you select GraphQL as the type, then continue by clicking Next.

3. Specifying GraphQL Schema Source

The next step requires you to specify the source of your GraphQL schema. It's important to ensure that the file you intend to use as your schema source has the appropriate extension. Navigate to the location of your target schema file, which must have either a .graphql or .gql extension. Select this file, and then click Finish to complete the setup process.

4. Reviewing the Created API

Upon completion, the GraphQL API editor will open, displaying your newly created API. This environment allows you to review and further configure your API as needed.

Martini automatically generates models and services based on the definitions within your schema, including object types, queries, and mutations. Additionally, a .api file is created, listing the available services. Your server can be accessed at the path .../api/<your-api-name>/graphql, and the schema is available at .../api/<your-api-name>/schema.graphql.